prophet 1.9.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: afe7d79d028a1b2365986a403441c0c83ddd8833
4
- data.tar.gz: 0819c0fd245bc51106ac93fda3a0f1669af8d8b0
2
+ SHA256:
3
+ metadata.gz: 4e0cdb6d0ea731019023c33f2a0e6896aa558ff84eafc2a1fdae9547b8865f90
4
+ data.tar.gz: 5e1797d1ffab25d7501a9ab15a2f7ac1ae03a52664e472beecc18f27fae1f307
5
5
  SHA512:
6
- metadata.gz: fa4ffda35c9052a9542259acf8fdb8508126ed0e523780faa604a39ee91c459b0da5978d994011a8be3503f10dcddb68b906206180772d9cbc93461b2c12f8a0
7
- data.tar.gz: 96c4720864de08183fc6532903b3c5da54bec83dc29274c7ba305e70c367ff3018c61b4c49c72425f3b14297a9d9e318f1a4c4d08257711eed8a263fa8e59c34
6
+ metadata.gz: 6d6ee5b15f1a9da9fea75ba516d8f238e6119a0e03fc72998206f012cf536760858f7bca294832e1689eaa6053afba922209b046aa48a3f8c31d6df1bf463156
7
+ data.tar.gz: 8d6fadd5de8798e92781db62657dcbede972266d7d7ad64fcea86930cff660e0b6018ad1cb647ee009056a935df37ce662469590760f38689c8ed46624bc6da7
@@ -164,66 +164,70 @@ class Prophet
164
164
  # - the pull request hasn't been used for a run before.
165
165
  # - the pull request has been updated since the last run.
166
166
  # - the target (i.e. master) has been updated since the last run.
167
+ # - the pull request does not originate from a fork (to avoid malicious code execution on CI machines)
167
168
  def run_necessary?
168
169
  logger.info "Checking pull request ##{@request.id}: #{@request.content.title}"
169
- # Compare current sha ids of target and source branch with those from the last test run.
170
- @request.target_head_sha = @github.commits(@project).first.sha
171
- comments = @github.issue_comments(@project, @request.id)
172
- comments = comments.select { |c| [username, username_fail].include?(c.user.login) }.reverse
173
- comments.each do |comment|
174
- @request.comment = comment if /Merged ([\w]+) into ([\w]+)/.match(comment.body)
175
- end
176
-
177
- statuses = @github.status(@project, @request.head_sha).statuses.select { |s| s.context == self.status_context }
178
- # Only run if it's mergeable.
179
- if @request.content.mergeable
180
- if statuses.empty?
181
- # If there is no status yet, it has to be a new request.
182
- logger.info 'New pull request detected, run needed.'
183
- return true
184
- elsif !self.disable_comments && !@request.comment
185
- logger.info 'Rerun forced.'
186
- return true
170
+ unless @request.from_fork
171
+ # Compare current sha ids of target and source branch with those from the last test run.
172
+ @request.target_head_sha = @github.commits(@project).first.sha
173
+ comments = @github.issue_comments(@project, @request.id)
174
+ comments = comments.select { |c| [username, username_fail].include?(c.user.login) }.reverse
175
+ comments.each do |comment|
176
+ @request.comment = comment if /Merged ([\w]+) into ([\w]+)/.match(comment.body)
187
177
  end
188
- else
189
- # Sometimes GitHub doesn't have a proper boolean value stored.
190
- if @request.content.mergeable.nil? && switch_branch_to_merged_state
191
- # Pull request is mergeable after all.
192
- switch_branch_back
178
+
179
+ statuses = @github.status(@project, @request.head_sha).statuses.select { |s| s.context == self.status_context }
180
+ # Only run if it's mergeable.
181
+ if @request.content.mergeable
182
+ if statuses.empty?
183
+ # If there is no status yet, it has to be a new request.
184
+ logger.info 'New pull request detected, run needed.'
185
+ return true
186
+ elsif !self.disable_comments && !@request.comment
187
+ logger.info 'Rerun forced.'
188
+ return true
189
+ end
193
190
  else
194
- logger.info 'Pull request not auto-mergeable. Not running.'
195
- if @request.comment
196
- logger.info 'Deleting existing comment.'
197
- call_github(old_comment_success?).delete_comment(@project, @request.comment.id)
191
+ # Sometimes GitHub doesn't have a proper boolean value stored.
192
+ if @request.content.mergeable.nil? && switch_branch_to_merged_state
193
+ # Pull request is mergeable after all.
194
+ switch_branch_back
195
+ else
196
+ logger.info 'Pull request not auto-mergeable. Not running.'
197
+ if @request.comment
198
+ logger.info 'Deleting existing comment.'
199
+ call_github(old_comment_success?).delete_comment(@project, @request.comment.id)
200
+ end
201
+ create_status(:error, "Pull request not auto-mergeable. Not running.") if statuses.first && statuses.first.state != 'error'
202
+ return false
198
203
  end
199
- create_status(:error, "Pull request not auto-mergeable. Not running.") if statuses.first && statuses.first.state != 'error'
200
- return false
201
204
  end
202
- end
203
205
 
204
- # Initialize shas to ensure it will live on after the 'each' block.
205
- shas = nil
206
- statuses.each do |status|
207
- shas = /Merged ([\w]+) into ([\w]+)/.match(status.description)
208
- break if shas && shas[1] && shas[2]
209
- end
206
+ # Initialize shas to ensure it will live on after the 'each' block.
207
+ shas = nil
208
+ statuses.each do |status|
209
+ shas = /Merged ([\w]+) into ([\w]+)/.match(status.description)
210
+ break if shas && shas[1] && shas[2]
211
+ end
210
212
 
211
- if shas
212
- logger.info "Current target sha: '#{@request.target_head_sha}', pull sha: '#{@request.head_sha}'."
213
- logger.info "Last test run target sha: '#{shas[2]}', pull sha: '#{shas[1]}'."
214
- if self.rerun_on_source_change && (shas[1] != @request.head_sha)
215
- logger.info 'Re-running due to new commit in pull request.'
213
+ if shas
214
+ logger.info "Current target sha: '#{@request.target_head_sha}', pull sha: '#{@request.head_sha}'."
215
+ logger.info "Last test run target sha: '#{shas[2]}', pull sha: '#{shas[1]}'."
216
+ if self.rerun_on_source_change && (shas[1] != @request.head_sha)
217
+ logger.info 'Re-running due to new commit in pull request.'
218
+ return true
219
+ elsif self.rerun_on_target_change && (shas[2] != @request.target_head_sha)
220
+ logger.info 'Re-running due to new commit in target branch.'
221
+ return true
222
+ end
223
+ else
224
+ # If there are no SHAs yet, it has to be a new request.
225
+ logger.info 'New pull request detected, run needed.'
216
226
  return true
217
- elsif self.rerun_on_target_change && (shas[2] != @request.target_head_sha)
218
- logger.info 'Re-running due to new commit in target branch.'
219
- return true
220
227
  end
221
- else
222
- # If there are no SHAs yet, it has to be a new request.
223
- logger.info 'New pull request detected, run needed.'
224
- return true
225
228
  end
226
229
 
230
+ logger.info "Pull request comes from a fork." if @request.from_fork
227
231
  logger.info "Not running for request ##{@request.id}."
228
232
  false
229
233
  end
@@ -4,12 +4,14 @@ class PullRequest
4
4
  :content,
5
5
  :comment,
6
6
  :head_sha,
7
- :target_head_sha
7
+ :target_head_sha,
8
+ :from_fork
8
9
 
9
10
  def initialize(content)
10
11
  @content = content
11
12
  @id = content.number
12
13
  @head_sha = content.head.sha
14
+ @from_fork = content.head.repo.fork
13
15
  end
14
16
 
15
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prophet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Bamberger
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-06 00:00:00.000000000 Z
13
+ date: 2018-05-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday_middleware
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.6.8
92
+ rubygems_version: 2.7.3
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: An easy way to loop through open pull requests and run code onthe merged