pullermann 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/pullermann/pullermann.rb +18 -10
  2. metadata +2 -2
@@ -54,6 +54,7 @@ class Pullermann
54
54
  # Run code on all selected requests.
55
55
  selected_requests.each do |request|
56
56
  @request = request
57
+ @log.info "Running for request ##{@request.id}."
57
58
  # GitHub always creates a merge commit for its 'Merge Button'.
58
59
  # Pullermann reuses that commit to run the code on it.
59
60
  switch_branch_to_merged_state
@@ -166,20 +167,26 @@ class Pullermann
166
167
  end
167
168
  # If it's not mergeable, we need to delete all comments of former test runs.
168
169
  unless @request.content.mergeable
169
- @log.info 'Pull request not auto-mergeable. Not running.'
170
- if @request.comment
171
- @log.info 'Deleting existing comment.'
172
- call_github(old_comment_success?).delete_comment(@project, @request.comment.id)
170
+ # Sometimes GitHub doesn't have a proper boolean value stored.
171
+ if @request.content.mergeable.nil? && switch_branch_to_merged_state(false)
172
+ # Pull request is mergeable after all.
173
+ switch_branch_back
174
+ else
175
+ @log.info 'Pull request not auto-mergeable. Not running.'
176
+ if @request.comment
177
+ @log.info 'Deleting existing comment.'
178
+ call_github(old_comment_success?).delete_comment(@project, @request.comment.id)
179
+ end
180
+ return false
173
181
  end
174
- return false
175
182
  end
176
183
  if @request.comment
177
184
  @log.info "Current target sha: '#{@request.target_head_sha}', pull sha: '#{@request.head_sha}'."
178
- @log.info "Last test run target sha: '#{shas[1]}', pull sha: '#{shas[2]}'."
179
- if self.rerun_on_source_change && (shas[2] != @request.head_sha)
185
+ @log.info "Last test run target sha: '#{shas[2]}', pull sha: '#{shas[1]}'."
186
+ if self.rerun_on_source_change && (shas[1] != @request.head_sha)
180
187
  @log.info 'Re-running due to new commit in pull request.'
181
188
  return true
182
- elsif self.rerun_on_target_change && (shas[1] != @request.target_head_sha)
189
+ elsif self.rerun_on_target_change && (shas[2] != @request.target_head_sha)
183
190
  @log.info 'Re-running due to new commit in target branch.'
184
191
  return true
185
192
  end
@@ -192,7 +199,7 @@ class Pullermann
192
199
  false
193
200
  end
194
201
 
195
- def switch_branch_to_merged_state
202
+ def switch_branch_to_merged_state(hard = true)
196
203
  # Fetch the merge-commit for the pull request.
197
204
  # NOTE: This commit is automatically created by 'GitHub Merge Button'.
198
205
  # FIXME: Use cheetah to pipe to @log.debug instead of that /dev/null hack.
@@ -200,8 +207,9 @@ class Pullermann
200
207
  `git checkout FETCH_HEAD &> /dev/null`
201
208
  unless $? == 0
202
209
  @log.error 'Unable to switch to merge branch.'
203
- abort
210
+ hard ? abort : false
204
211
  end
212
+ true
205
213
  end
206
214
 
207
215
  def switch_branch_back
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pullermann
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-09-20 00:00:00.000000000 Z
14
+ date: 2012-09-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: octokit