pullermann 1.0.1 → 1.0.2
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.
- data/lib/pullermann/pullermann.rb +28 -33
- metadata +2 -2
@@ -116,46 +116,41 @@ class Pullermann
|
|
116
116
|
def test_run_necessary?
|
117
117
|
pull_request = @github.pull_request @project, @request_id
|
118
118
|
@log.info "Checking pull request ##{@request_id}: #{pull_request.title}"
|
119
|
-
# If it's not mergeable, there is no point in going on.
|
120
|
-
unless pull_request.mergeable
|
121
|
-
@log.info 'Pull request not auto-mergeable, skipping... '
|
122
|
-
return false
|
123
|
-
end
|
124
119
|
# Compare current sha ids of target and source branch with those from the last test run.
|
125
120
|
@target_head_sha = @github.commits(@project).first.sha
|
126
121
|
@pull_head_sha = pull_request.head.sha
|
127
122
|
comments = @github.issue_comments(@project, @request_id)
|
128
123
|
comments = comments.select{ |c| [username, username_fail].include?(c.user.login) }.reverse
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
else
|
134
|
-
# Initialize shas to ensure it will live on after the 'each' block.
|
135
|
-
shas = nil
|
136
|
-
comments.each do |comment|
|
137
|
-
shas = /master sha# ([\w]+) ; pull sha# ([\w]+)/.match(comment.body)
|
138
|
-
if shas && shas[1] && shas[2]
|
139
|
-
# Remember @comment to be able to update or delete it later.
|
140
|
-
@comment = comment
|
141
|
-
break
|
142
|
-
end
|
143
|
-
end
|
144
|
-
# We finally found the latest comment that includes the necessary information.
|
124
|
+
# Initialize shas to ensure it will live on after the 'each' block.
|
125
|
+
shas = nil
|
126
|
+
comments.each do |comment|
|
127
|
+
shas = /master sha# ([\w]+) ; pull sha# ([\w]+)/.match(comment.body)
|
145
128
|
if shas && shas[1] && shas[2]
|
146
|
-
@
|
147
|
-
@
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
129
|
+
# Remember @comment to be able to update or delete it later.
|
130
|
+
@comment = comment
|
131
|
+
break
|
132
|
+
end
|
133
|
+
end
|
134
|
+
# If it's not mergeable, we need to delete all comments of former test runs.
|
135
|
+
unless pull_request.mergeable
|
136
|
+
@log.info 'Pull request not auto-mergeable, skipping... '
|
137
|
+
call_github(old_comment_success?).delete_comment(@project, @comment.id) if @comment
|
138
|
+
return false
|
139
|
+
end
|
140
|
+
if @comment
|
141
|
+
@log.info "Current target sha: '#{@target_head_sha}', pull sha: '#{@pull_head_sha}'."
|
142
|
+
@log.info "Last test run target sha: '#{shas[1]}', pull sha: '#{shas[2]}'."
|
143
|
+
if self.rerun_on_source_change && (shas[2] != @pull_head_sha)
|
144
|
+
@log.info 'Re-running test due to new commit in pull request.'
|
145
|
+
return true
|
146
|
+
elsif self.rerun_on_target_change && (shas[1] != @target_head_sha)
|
147
|
+
@log.info 'Re-running test due to new commit in target branch.'
|
157
148
|
return true
|
158
149
|
end
|
150
|
+
else
|
151
|
+
# If there are no comments yet, it has to be a new request.
|
152
|
+
@log.info 'New pull request detected, test run needed.'
|
153
|
+
return true
|
159
154
|
end
|
160
155
|
@log.info "Not running tests for request ##{@request_id}."
|
161
156
|
false
|
@@ -185,7 +180,7 @@ class Pullermann
|
|
185
180
|
def old_comment_success?
|
186
181
|
return unless @comment
|
187
182
|
# Determine boolean value.
|
188
|
-
@comment
|
183
|
+
@comment.body.include? 'Well done!'
|
189
184
|
end
|
190
185
|
|
191
186
|
# Output the result to a comment on the pull request on GitHub.
|
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.0.
|
4
|
+
version: 1.0.2
|
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-06-
|
14
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: octokit
|