danger 5.5.7 → 5.5.8

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
2
  SHA1:
3
- metadata.gz: ac631daf8aaea436429afb68d8a534b84b03c9a9
4
- data.tar.gz: aed843fe3d16f9e09fa1b1b0dbb300e0cb33f958
3
+ metadata.gz: 337bfe88532b4d8aaa67f9c93deab2cf92e886e8
4
+ data.tar.gz: 37e0165d0efe4a723c95f04d8af35b7a19b12888
5
5
  SHA512:
6
- metadata.gz: d84b21f613d955ebac96ad8561126d53eb6caff28959909d10d9061e4204a470714500e98674375db4a4e405173a788e64113ef31a994429164ec5b00e979a79
7
- data.tar.gz: d80f497254260a8d6cc65e61c92b7a9ac0cf7b660cb94e7e4b7d82791a02c010ff78bc36a4c5bf3ecc0c42a587641f49e238af265e672072dd8bba293cfa4e77
6
+ metadata.gz: b458d47ed3012209f8ada90aaaa70342b4d7580420746cd51d5e0edebeec4d6d9895fe7e9783f24b2026d3d03ae0b571eab53e9503700573290d7bbbb3f29b10
7
+ data.tar.gz: d57f5833a0727e64acd73a111e6d37bcca0b2a578161788b1aba7080907b7711e3dde73b5ebb926f666a552e9d8c4470cea21f435bcf66b3b1b015a1718ebd84
@@ -58,6 +58,7 @@ module Danger
58
58
  Danger::EnvironmentManager.danger_head_branch,
59
59
  @dangerfile_path,
60
60
  nil,
61
+ nil,
61
62
  nil
62
63
  )
63
64
  end
@@ -63,6 +63,7 @@ module Danger
63
63
  Danger::EnvironmentManager.danger_head_branch,
64
64
  @dangerfile_path,
65
65
  nil,
66
+ nil,
66
67
  nil
67
68
  )
68
69
  end
@@ -38,6 +38,7 @@ module Danger
38
38
  @head = argv.option("head")
39
39
  @fail_on_errors = argv.option("fail-on-errors", false)
40
40
  @new_comment = argv.flag?("new-comment")
41
+ @remove_previous_comments = argv.flag?("remove-previous-comments")
41
42
  @danger_id = argv.option("danger_id", "danger")
42
43
  @cork = Cork::Board.new(silent: argv.option("silent", false),
43
44
  verbose: argv.option("verbose", false))
@@ -58,7 +59,8 @@ module Danger
58
59
  ["--fail-on-errors=<true|false>", "Should always fail the build process, defaults to false"],
59
60
  ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
60
61
  ["--danger_id=<id>", "The identifier of this Danger instance"],
61
- ["--new-comment", "Makes Danger post a new comment instead of editing its previous one"]
62
+ ["--new-comment", "Makes Danger post a new comment instead of editing its previous one"],
63
+ ["--remove-previous-comments", "Removes all previous comment and create a new one in the end of the list"]
62
64
  ].concat(super)
63
65
  end
64
66
 
@@ -69,7 +71,8 @@ module Danger
69
71
  dangerfile_path: @dangerfile_path,
70
72
  danger_id: @danger_id,
71
73
  new_comment: @new_comment,
72
- fail_on_errors: @fail_on_errors
74
+ fail_on_errors: @fail_on_errors,
75
+ remove_previous_comments: @remove_previous_comments
73
76
  )
74
77
  end
75
78
  end
@@ -242,7 +242,7 @@ module Danger
242
242
  violation_report[:errors].count > 0
243
243
  end
244
244
 
245
- def post_results(danger_id, new_comment)
245
+ def post_results(danger_id, new_comment, remove_previous_comments)
246
246
  violations = violation_report
247
247
 
248
248
  env.request_source.update_pull_request!(
@@ -251,7 +251,8 @@ module Danger
251
251
  messages: violations[:messages].uniq,
252
252
  markdowns: status_report[:markdowns].uniq,
253
253
  danger_id: danger_id,
254
- new_comment: new_comment
254
+ new_comment: new_comment,
255
+ remove_previous_comments: remove_previous_comments
255
256
  )
256
257
  end
257
258
 
@@ -260,7 +261,7 @@ module Danger
260
261
  env.scm.diff_for_folder(".".freeze, from: base_branch, to: head_branch)
261
262
  end
262
263
 
263
- def run(base_branch, head_branch, dangerfile_path, danger_id, new_comment)
264
+ def run(base_branch, head_branch, dangerfile_path, danger_id, new_comment, remove_previous_comments)
264
265
  # Setup internal state
265
266
  init_plugins
266
267
  env.fill_environment_vars
@@ -275,7 +276,7 @@ module Danger
275
276
  # Push results to the API
276
277
  # Pass along the details of the run to the request source
277
278
  # to send back to the code review site.
278
- post_results(danger_id, new_comment) unless danger_id.nil?
279
+ post_results(danger_id, new_comment, remove_previous_comments) unless danger_id.nil?
279
280
 
280
281
  # Print results in the terminal
281
282
  print_results
@@ -12,7 +12,8 @@ module Danger
12
12
  dangerfile_path: nil,
13
13
  danger_id: nil,
14
14
  new_comment: nil,
15
- fail_on_errors: nil)
15
+ fail_on_errors: nil,
16
+ remove_previous_comments: nil)
16
17
  # Create a silent Cork instance if cork is nil, as it's likely a test
17
18
  cork ||= Cork::Board.new(silent: false, verbose: false)
18
19
 
@@ -29,7 +30,8 @@ module Danger
29
30
  head_branch(head),
30
31
  dangerfile_path,
31
32
  danger_id,
32
- new_comment
33
+ new_comment,
34
+ remove_previous_comments
33
35
  )
34
36
  end
35
37
 
@@ -64,8 +64,8 @@ module Danger
64
64
  nil
65
65
  end
66
66
 
67
- def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false)
68
- delete_old_comments(danger_id: danger_id) unless new_comment
67
+ def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false, remove_previous_comments: false)
68
+ delete_old_comments(danger_id: danger_id) if !new_comment || remove_previous_comments
69
69
 
70
70
  comment = generate_description(warnings: warnings, errors: errors)
71
71
  comment += "\n\n"
@@ -70,8 +70,8 @@ module Danger
70
70
  nil
71
71
  end
72
72
 
73
- def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false)
74
- delete_old_comments(danger_id: danger_id) unless new_comment
73
+ def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false, remove_previous_comments: false)
74
+ delete_old_comments(danger_id: danger_id) if !new_comment || remove_previous_comments
75
75
 
76
76
  comment = generate_description(warnings: warnings, errors: errors)
77
77
  comment += "\n\n"
@@ -140,11 +140,11 @@ module Danger
140
140
  end
141
141
 
142
142
  # Sending data to GitHub
143
- def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false)
143
+ def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false, remove_previous_comments: false)
144
144
  comment_result = {}
145
145
  editable_comments = issue_comments.select { |comment| comment.generated_by_danger?(danger_id) }
146
146
  last_comment = editable_comments.last
147
- should_create_new_comment = new_comment || last_comment.nil?
147
+ should_create_new_comment = new_comment || last_comment.nil? || remove_previous_comments
148
148
 
149
149
  previous_violations =
150
150
  if should_create_new_comment
@@ -178,8 +178,8 @@ module Danger
178
178
 
179
179
  main_violations_sum = main_violations.values.inject(:+)
180
180
 
181
- if previous_violations.empty? && main_violations_sum.empty?
182
- # Just remove the comment, if there's nothing to say.
181
+ if (previous_violations.empty? && main_violations_sum.empty?) || remove_previous_comments
182
+ # Just remove the comment, if there's nothing to say or --remove-previous-comments CLI was set.
183
183
  delete_old_comments!(danger_id: danger_id)
184
184
  end
185
185
 
@@ -116,10 +116,10 @@ module Danger
116
116
  GetIgnoredViolation.new(self.mr_json.description).call
117
117
  end
118
118
 
119
- def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false)
119
+ def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false, remove_previous_comments: false)
120
120
  editable_comments = mr_comments.select { |comment| comment.generated_by_danger?(danger_id) }
121
121
 
122
- should_create_new_comment = new_comment || editable_comments.empty?
122
+ should_create_new_comment = new_comment || editable_comments.empty? || remove_previous_comments
123
123
 
124
124
  if should_create_new_comment
125
125
  previous_violations = {}
@@ -128,8 +128,8 @@ module Danger
128
128
  previous_violations = parse_comment(comment)
129
129
  end
130
130
 
131
- if previous_violations.empty? && (warnings + errors + messages + markdowns).empty?
132
- # Just remove the comment, if there"s nothing to say.
131
+ if (previous_violations.empty? && (warnings + errors + messages + markdowns).empty?) || remove_previous_comments
132
+ # Just remove the comment, if there's nothing to say or --remove-previous-comments CLI was set.
133
133
  delete_old_comments!(danger_id: danger_id)
134
134
  else
135
135
  body = generate_comment(warnings: warnings,
@@ -72,7 +72,7 @@ module Danger
72
72
  nil
73
73
  end
74
74
 
75
- def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false)
75
+ def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false, remove_previous_comments: false)
76
76
  unless @api.supports_comments?
77
77
  return
78
78
  end
@@ -86,7 +86,7 @@ module Danger
86
86
  previous_violations: {},
87
87
  danger_id: danger_id,
88
88
  template: "vsts")
89
- if new_comment
89
+ if new_comment || remove_previous_comments
90
90
  post_new_comment(comment)
91
91
  else
92
92
  update_old_comment(comment, danger_id: danger_id)
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "5.5.7".freeze
2
+ VERSION = "5.5.8".freeze
3
3
  DESCRIPTION = "Like Unit Tests, but for your Team Culture.".freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.7
4
+ version: 5.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orta Therox
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-24 00:00:00.000000000 Z
12
+ date: 2018-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide