gitarro 0.1.81 → 0.1.82

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gitarro/backend.rb +28 -18
  3. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a024ef58673cf6412c7fb1b474bccc5a5555cd0d8d0c9690c63f3a469742b540
4
- data.tar.gz: 41b718de88bb09a3d9fe98681db4e38acbfed512b9058708bf004f408d75ee0c
3
+ metadata.gz: bb333ee96f4cfecebfe8a2cc7738cb460fbc6d1961fc01a4f37db171e2baf03a
4
+ data.tar.gz: 4b010669bd1a5bb0c426a324fd3251d4956cd56033f48814002ae26f5b6d59ea
5
5
  SHA512:
6
- metadata.gz: 167da6114d2d545b4145e18ae737bd7d7e1254a2ab09c5ecbcf1d966873815cba84b45c27394d37f0923e22106b00bb5f11225c23a1084ca3bedd99c12f6f53d
7
- data.tar.gz: 31a15bcce8985b8227a8cc752be768f738bf57245252cdd115c3c7bd69939f83a0dc0694b90769dbf6789a85b67918e6b09e874594c168d5d8121579217f45b7
6
+ metadata.gz: fdbe35a2bc89886846ba84e39d650e2424c275014c9a73a63feeb6fbc2e83c85748f60417ce03650c10e2e1de6fcbad7e5d87dee10d6023c674c126c2b58ef26
7
+ data.tar.gz: 243b2462f6376a2fa94eb9d010c7e871061141937c9d638ae5cb3cace734431d5395967c039f8c49fcc45c4e7e2518b8fe6f52cce0999f91984d3053dc9502e0
@@ -88,9 +88,8 @@ class TestExecutor
88
88
  # this will clone the repo and execute the tests
89
89
  def pr_test(pr)
90
90
  clone_repo(@noshallow, pr)
91
- # do valid tests and store the result
92
- test_status = run_script
93
- test_status
91
+ # do valid tests and return the result
92
+ run_script
94
93
  end
95
94
 
96
95
  # run validation script for validating the PR.
@@ -120,10 +119,7 @@ class TestExecutor
120
119
 
121
120
  def export_pr_data_to_json_file(pr)
122
121
  pr = pr.to_hash
123
- pr[:files] = []
124
- @client.pull_request_files(@repo, pr[:number]).each do |github_file|
125
- pr[:files].push(github_file.to_hash)
126
- end
122
+ pr[:files] = @client.pull_request_files(@repo, pr[:number]).map(&:to_h)
127
123
  File.open('.gitarro_pr.json', 'w') do |file|
128
124
  file.write(JSON.generate(pr))
129
125
  end
@@ -182,7 +178,7 @@ class Backend
182
178
  return true if @branch == pr.base.ref
183
179
 
184
180
  puts "branch \"#{pr.base.ref}\" should match github-branch \"#{@branch}\" (given) !!!"
185
- puts "skipping tests !!!"
181
+ puts 'skipping tests !!!'
186
182
  false
187
183
  end
188
184
 
@@ -204,7 +200,7 @@ class Backend
204
200
  print_test_required
205
201
  gbexec.export_pr_data(pr)
206
202
  exit 0 if @check
207
- launch_test_and_setup_status(pr) == 'success' ? exit(0) : exit(1)
203
+ launch_test_and_setup_status(pr)
208
204
  end
209
205
 
210
206
  # public always rerun tests against the pr number if this exists
@@ -215,7 +211,7 @@ class Backend
215
211
  puts "Got triggered by PR_NUMBER OPTION, rerunning on #{@pr_number}"
216
212
  print_test_required
217
213
  gbexec.export_pr_data(pr_on_number)
218
- launch_test_and_setup_status(pr_on_number) == 'success' ? exit(0) : exit(1)
214
+ launch_test_and_setup_status(pr_on_number)
219
215
  end
220
216
 
221
217
  def unreviewed_new_pr?(pr, comm_st)
@@ -230,7 +226,7 @@ class Backend
230
226
  gbexec.export_pr_data(pr)
231
227
  return false if @check
232
228
 
233
- launch_test_and_setup_status(pr) == 'success' ? exit(0) : exit(1)
229
+ launch_test_and_setup_status(pr)
234
230
  end
235
231
 
236
232
  def reviewed_pr?(comm_st, pr)
@@ -243,7 +239,7 @@ class Backend
243
239
  print_test_required
244
240
  gbexec.export_pr_data(pr)
245
241
  exit(0) if @check
246
- launch_test_and_setup_status(pr) == 'success' ? exit(0) : exit(1)
242
+ launch_test_and_setup_status(pr)
247
243
  end
248
244
 
249
245
  # this function will check if the PR contains in comment the magic word
@@ -253,14 +249,27 @@ class Backend
253
249
  # a pr contain always a comments, cannot be nil
254
250
  @client.issue_comments(@repo, pr_number).each do |com|
255
251
  # delete comment otherwise it will be retrigger infinetely
256
- if com.body.include? magic_word_trigger
257
- @client.delete_comment(@repo, com.id)
258
- return true
259
- end
252
+ next unless com.body.include? magic_word_trigger
253
+
254
+ puts "Re-run test \"#{context}\""
255
+ @client.delete_comment(@repo, com.id)
256
+ return true
260
257
  end
261
258
  false
262
259
  end
263
260
 
261
+ # this function will check if the PR contains a checkbox
262
+ # for retrigger all the tests.
263
+ def retriggered_by_checkbox?(pr, context)
264
+ return false unless pr.body.include? "[x] Re-run test \"#{context}\""
265
+
266
+ puts "Re-run test \"#{context}\""
267
+ new_pr_body = pr.body.gsub("[x] Re-run test \"#{context}\"",
268
+ "[ ] Re-run test \"#{context}\"")
269
+ @client.update_pull_request(@repo, pr.number, body: new_pr_body)
270
+ true
271
+ end
272
+
264
273
  private
265
274
 
266
275
  # Show a message stating if there are opened PRs or not
@@ -294,7 +303,7 @@ class Backend
294
303
  # set status
295
304
  create_status(pr, test_status)
296
305
  # return status for other functions
297
- test_status
306
+ test_status == 'success' ? exit(0) : exit(1)
298
307
  end
299
308
 
300
309
  # check all files of a Prs Number if they are a specific type
@@ -325,7 +334,8 @@ class Backend
325
334
 
326
335
  def retrigger_needed?(pr)
327
336
  # we want redo sometimes tests
328
- return false unless retriggered_by_comment?(pr.number, @context)
337
+ return false unless retriggered_by_checkbox?(pr, @context) ||
338
+ retriggered_by_comment?(pr, @context)
329
339
 
330
340
  # if check is set, the comment in the trigger job will be del.
331
341
  # so setting it to pending, it will be remembered
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitarro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.81
4
+ version: 0.1.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dario Maiocchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-01 00:00:00.000000000 Z
11
+ date: 2019-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: english
@@ -151,7 +151,8 @@ files:
151
151
  homepage: https://github.com/openSUSE/gitarro
152
152
  licenses:
153
153
  - MIT
154
- metadata: {}
154
+ metadata:
155
+ changelog_uri: https://github.com/openSUSE/gitarro/blob/master/CHANGELOG.md
155
156
  post_install_message:
156
157
  rdoc_options: []
157
158
  require_paths:
@@ -168,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  version: '0'
169
170
  requirements: []
170
171
  rubyforge_project:
171
- rubygems_version: 2.7.3
172
+ rubygems_version: 2.7.6
172
173
  signing_key:
173
174
  specification_version: 4
174
175
  summary: gitarro gem