danger 5.2.2 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/danger/ci_source/jenkins.rb +5 -0
- data/lib/danger/commands/init.rb +8 -3
- data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +8 -0
- data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +10 -3
- data/lib/danger/request_sources/github/github.rb +21 -18
- data/lib/danger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 280aa14f35fab7d31eca02ca079f3fd139f3f4ba
|
4
|
+
data.tar.gz: 356443a6e67ca27bf08cb760b96bfe909d3b40ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3fe03e6240ad5b9ef1fd1efe6161b46ce562ca5d851ed5f01719d52679c7f31124e3f920746ee97a5c445e5d751b8dff340b0e7f57cdc4ec441ca8fc896d119
|
7
|
+
data.tar.gz: d2ce6b122c7727f462aa53ca5b2d1797007bb8e811bbcb59fa1a0deaa722f5368c3d542cdfbd0622407cf38e168617d54f9ec31c35ee6c9afd601b8d3559e421
|
@@ -29,6 +29,11 @@ module Danger
|
|
29
29
|
#
|
30
30
|
# With that set up, you can edit your job to add `bundle exec danger` at the build action.
|
31
31
|
#
|
32
|
+
# #### General
|
33
|
+
#
|
34
|
+
# People occasionally see issues with Danger not classing your CI runs as a PR, to give you visibilty
|
35
|
+
# the Jenkins side of Danger expects to see one of these env vars: ghprbPullId, CHANGE_ID or gitlabMergeRequestId
|
36
|
+
#
|
32
37
|
# ### Token Setup
|
33
38
|
#
|
34
39
|
# #### GitHub
|
data/lib/danger/commands/init.rb
CHANGED
@@ -143,9 +143,14 @@ module Danger
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def current_repo_slug
|
146
|
-
|
147
|
-
|
148
|
-
(
|
146
|
+
git = GitRepo.new
|
147
|
+
|
148
|
+
author_repo_regexp = %r{(?:[\/:])([^\/]+\/[^\/]+)(?:.git)?$}
|
149
|
+
last_git_regexp = /.git$/
|
150
|
+
|
151
|
+
matches = git.origins.match(author_repo_regexp)
|
152
|
+
|
153
|
+
matches ? matches[1].gsub(last_git_regexp, "").strip : "[Your/Repo]"
|
149
154
|
end
|
150
155
|
|
151
156
|
def setup_danger_ci
|
@@ -83,6 +83,14 @@ module Danger
|
|
83
83
|
@git.renamed_files
|
84
84
|
end
|
85
85
|
|
86
|
+
# @!group Git Metadata
|
87
|
+
# Whole diff
|
88
|
+
# @return [Git::Diff] from the gem `git`
|
89
|
+
#
|
90
|
+
def diff
|
91
|
+
@git.diff
|
92
|
+
end
|
93
|
+
|
86
94
|
# @!group Git Metadata
|
87
95
|
# The overall lines of code added/removed in the diff
|
88
96
|
# @return [Fixnum]
|
@@ -226,12 +226,19 @@ module Danger
|
|
226
226
|
|
227
227
|
# @!group GitHub Misc
|
228
228
|
# Use to ignore inline messages which lay outside a diff's range, thereby not posting them in the main comment.
|
229
|
-
#
|
229
|
+
# You can set hash to change behavior per each kinds. (ex. `{warning: true, error: false}`)
|
230
|
+
# @param [Bool] or [Hash<Symbol, Bool>] dismiss
|
230
231
|
# Ignore out of range inline messages, defaults to `true`
|
231
232
|
#
|
232
233
|
# @return [void]
|
233
|
-
def dismiss_out_of_range_messages(dismiss
|
234
|
-
|
234
|
+
def dismiss_out_of_range_messages(dismiss = true)
|
235
|
+
if dismiss.kind_of?(Hash)
|
236
|
+
@github.dismiss_out_of_range_messages = dismiss
|
237
|
+
elsif dismiss.kind_of?(TrueClass)
|
238
|
+
@github.dismiss_out_of_range_messages = true
|
239
|
+
elsif dismiss.kind_of?(FalseClass)
|
240
|
+
@github.dismiss_out_of_range_messages = false
|
241
|
+
end
|
235
242
|
end
|
236
243
|
|
237
244
|
%i(title body author labels json).each do |suffix|
|
@@ -245,18 +245,10 @@ module Danger
|
|
245
245
|
danger_comments = pr_comments.select { |comment| Comment.from_github(comment).generated_by_danger?(danger_id) }
|
246
246
|
non_danger_comments = pr_comments - danger_comments
|
247
247
|
|
248
|
-
warnings = submit_inline_comments_for_kind!(
|
249
|
-
|
250
|
-
)
|
251
|
-
|
252
|
-
"no_entry_sign", errors, diff_lines, danger_comments, previous_violations["error"], danger_id: danger_id
|
253
|
-
)
|
254
|
-
messages = submit_inline_comments_for_kind!(
|
255
|
-
"book", messages, diff_lines, danger_comments, previous_violations["message"], danger_id: danger_id
|
256
|
-
)
|
257
|
-
markdowns = submit_inline_comments_for_kind!(
|
258
|
-
nil, markdowns, diff_lines, danger_comments, [], danger_id: danger_id
|
259
|
-
)
|
248
|
+
warnings = submit_inline_comments_for_kind!(:warning, warnings, diff_lines, danger_comments, previous_violations["warning"], danger_id: danger_id)
|
249
|
+
errors = submit_inline_comments_for_kind!(:error, errors, diff_lines, danger_comments, previous_violations["error"], danger_id: danger_id)
|
250
|
+
messages = submit_inline_comments_for_kind!(:message, messages, diff_lines, danger_comments, previous_violations["message"], danger_id: danger_id)
|
251
|
+
markdowns = submit_inline_comments_for_kind!(:markdown, markdowns, diff_lines, danger_comments, [], danger_id: danger_id)
|
260
252
|
|
261
253
|
# submit removes from the array all comments that are still in force
|
262
254
|
# so we strike out all remaining ones
|
@@ -293,18 +285,19 @@ module Danger
|
|
293
285
|
m1.message.sub(blob_regexp, "") == m2.message.sub(blob_regexp, "")
|
294
286
|
end
|
295
287
|
|
296
|
-
def submit_inline_comments_for_kind!(
|
288
|
+
def submit_inline_comments_for_kind!(kind, messages, diff_lines, danger_comments, previous_violations, danger_id: "danger")
|
297
289
|
head_ref = pr_json["head"]["sha"]
|
298
290
|
previous_violations ||= []
|
299
|
-
is_markdown_content =
|
291
|
+
is_markdown_content = kind == :markdown
|
292
|
+
emoji = { warning: "warning", error: "no_entry_sign", message: "book" }[kind]
|
300
293
|
|
301
294
|
messages.reject do |m|
|
302
295
|
next false unless m.file && m.line
|
303
296
|
|
304
|
-
position = find_position_in_diff diff_lines, m
|
297
|
+
position = find_position_in_diff diff_lines, m, kind
|
305
298
|
|
306
299
|
# Keep the change if it's line is not in the diff and not in dismiss mode
|
307
|
-
next
|
300
|
+
next dismiss_out_of_range_messages_for(kind) if position.nil?
|
308
301
|
|
309
302
|
# Once we know we're gonna submit it, we format it
|
310
303
|
if is_markdown_content
|
@@ -349,7 +342,7 @@ module Danger
|
|
349
342
|
end
|
350
343
|
end
|
351
344
|
|
352
|
-
def find_position_in_diff(diff_lines, message)
|
345
|
+
def find_position_in_diff(diff_lines, message, kind)
|
353
346
|
range_header_regexp = /@@ -([0-9]+),([0-9]+) \+(?<start>[0-9]+)(,(?<end>[0-9]+))? @@.*/
|
354
347
|
file_header_regexp = %r{^diff --git a/.*}
|
355
348
|
|
@@ -372,7 +365,7 @@ module Danger
|
|
372
365
|
# so we do it one by one ignoring the deleted lines
|
373
366
|
if !file_line.nil? && !line.start_with?("-")
|
374
367
|
if file_line == message.line
|
375
|
-
file_line = nil if
|
368
|
+
file_line = nil if dismiss_out_of_range_messages_for(kind) && !line.start_with?("+")
|
376
369
|
break
|
377
370
|
end
|
378
371
|
file_line += 1
|
@@ -432,6 +425,16 @@ module Danger
|
|
432
425
|
nil
|
433
426
|
end
|
434
427
|
|
428
|
+
def dismiss_out_of_range_messages_for(kind)
|
429
|
+
if self.dismiss_out_of_range_messages.kind_of?(Hash) && self.dismiss_out_of_range_messages[kind]
|
430
|
+
self.dismiss_out_of_range_messages[kind]
|
431
|
+
elsif self.dismiss_out_of_range_messages == true
|
432
|
+
self.dismiss_out_of_range_messages
|
433
|
+
else
|
434
|
+
false
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
435
438
|
# @return [String] A URL to the specific file, ready to be downloaded
|
436
439
|
def file_url(organisation: nil, repository: nil, branch: nil, path: nil)
|
437
440
|
organisation ||= self.organisation
|
data/lib/danger/version.rb
CHANGED
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.
|
4
|
+
version: 5.3.0
|
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: 2017-
|
12
|
+
date: 2017-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|