danger 8.0.5 → 8.0.6
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b175fad0150fdcb243c42f37c0b9683a7dc00db8b3be4ef81d01be0103b90bb
|
4
|
+
data.tar.gz: d422bf7eadd533e5591f1ac43cde404f38d124a3c398469a1b9563c5338e8370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d36a05ed7713cf0b50936c04feaa4cb49c8ba035b539ff265c9d7e231c2670efba007f5f4a2bf58936cab24c7aa0e09d5c9a2a9edff9714689fc5b03cc31d870
|
7
|
+
data.tar.gz: 611a647c06bab7c3949ded7ff12b5498b966d54f10056481ae720dfa3801f48ac27085d112f69c186feb5638b2b82b0f7583c0f020af33af8251705429fbf614
|
@@ -9,7 +9,7 @@ module Danger
|
|
9
9
|
def include?(pattern)
|
10
10
|
self.each do |current|
|
11
11
|
unless current.nil?
|
12
|
-
return true if File.fnmatch(pattern, current) || pattern == current
|
12
|
+
return true if File.fnmatch(pattern, current, File::FNM_EXTGLOB) || pattern == current
|
13
13
|
end
|
14
14
|
end
|
15
15
|
return false
|
@@ -227,6 +227,23 @@ module Danger
|
|
227
227
|
paths.first(paths.count - 1).join(", ") + " & " + paths.last
|
228
228
|
end
|
229
229
|
|
230
|
+
# @!group Gitlab Misc
|
231
|
+
# Use to ignore inline messages which lay outside a diff's range, thereby not posting the comment.
|
232
|
+
# You can set hash to change behavior per each kinds. (ex. `{warning: true, error: false}`)
|
233
|
+
# @param [Bool] or [Hash<Symbol, Bool>] dismiss
|
234
|
+
# Ignore out of range inline messages, defaults to `true`
|
235
|
+
#
|
236
|
+
# @return [void]
|
237
|
+
def dismiss_out_of_range_messages(dismiss = true)
|
238
|
+
if dismiss.kind_of?(Hash)
|
239
|
+
@gitlab.dismiss_out_of_range_messages = dismiss
|
240
|
+
elsif dismiss.kind_of?(TrueClass)
|
241
|
+
@gitlab.dismiss_out_of_range_messages = true
|
242
|
+
elsif dismiss.kind_of?(FalseClass)
|
243
|
+
@gitlab.dismiss_out_of_range_messages = false
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
230
247
|
%i(title body author labels json diff).each do |suffix|
|
231
248
|
alias_method "pr_#{suffix}".to_sym, "mr_#{suffix}".to_sym
|
232
249
|
end
|
@@ -11,7 +11,7 @@ module Danger
|
|
11
11
|
include Danger::Helpers::CommentsParsingHelper
|
12
12
|
|
13
13
|
def markdown_parser(text)
|
14
|
-
Kramdown::Document.new(text, input: "GFM")
|
14
|
+
Kramdown::Document.new(text, input: "GFM", smart_quotes: %w[apos apos quot quot])
|
15
15
|
end
|
16
16
|
|
17
17
|
# !@group Extension points
|
@@ -8,7 +8,7 @@ module Danger
|
|
8
8
|
module RequestSources
|
9
9
|
class GitLab < RequestSource
|
10
10
|
include Danger::Helpers::CommentsHelper
|
11
|
-
attr_accessor :mr_json, :commits_json
|
11
|
+
attr_accessor :mr_json, :commits_json, :dismiss_out_of_range_messages
|
12
12
|
|
13
13
|
FIRST_GITLAB_GEM_WITH_VERSION_CHECK = Gem::Version.new("4.6.0")
|
14
14
|
FIRST_VERSION_WITH_INLINE_COMMENTS = Gem::Version.new("10.8.0")
|
@@ -24,6 +24,7 @@ module Danger
|
|
24
24
|
def initialize(ci_source, environment)
|
25
25
|
self.ci_source = ci_source
|
26
26
|
self.environment = environment
|
27
|
+
self.dismiss_out_of_range_messages = false
|
27
28
|
|
28
29
|
@token = @environment["DANGER_GITLAB_API_TOKEN"]
|
29
30
|
end
|
@@ -302,6 +303,16 @@ module Danger
|
|
302
303
|
nil # TODO: Implement this
|
303
304
|
end
|
304
305
|
|
306
|
+
def dismiss_out_of_range_messages_for(kind)
|
307
|
+
if self.dismiss_out_of_range_messages.kind_of?(Hash) && self.dismiss_out_of_range_messages[kind]
|
308
|
+
self.dismiss_out_of_range_messages[kind]
|
309
|
+
elsif self.dismiss_out_of_range_messages == true
|
310
|
+
self.dismiss_out_of_range_messages
|
311
|
+
else
|
312
|
+
false
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
305
316
|
# @return [String] A URL to the specific file, ready to be downloaded
|
306
317
|
def file_url(organisation: nil, repository: nil, branch: nil, path: nil)
|
307
318
|
branch ||= 'master'
|
@@ -397,10 +408,9 @@ module Danger
|
|
397
408
|
|
398
409
|
messages.reject do |m|
|
399
410
|
next false unless m.file && m.line
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
411
|
+
# Reject if it's out of range and in dismiss mode
|
412
|
+
next true if dismiss_out_of_range_messages_for(kind) && is_out_of_range(mr_changes.changes, m)
|
413
|
+
|
404
414
|
# Once we know we're gonna submit it, we format it
|
405
415
|
if is_markdown_content
|
406
416
|
body = generate_inline_markdown_body(m, danger_id: danger_id, template: "gitlab")
|
@@ -473,7 +483,6 @@ module Danger
|
|
473
483
|
range_header_regexp = /@@ -(?<old>[0-9]+)(,([0-9]+))? \+(?<new>[0-9]+)(,([0-9]+))? @@.*/
|
474
484
|
|
475
485
|
change = changes.find { |c| c["new_path"] == message.file }
|
476
|
-
|
477
486
|
# If there is no changes or rename only or deleted, return nil.
|
478
487
|
return nil if change.nil? || change["diff"].empty? || change["deleted_file"]
|
479
488
|
|
@@ -520,6 +529,41 @@ module Danger
|
|
520
529
|
line: current_old_line - current_new_line + message.line.to_i
|
521
530
|
}
|
522
531
|
end
|
532
|
+
|
533
|
+
def is_out_of_range(changes, message)
|
534
|
+
change = changes.find { |c| c["new_path"] == message.file }
|
535
|
+
# If there is no changes or rename only or deleted, return out of range.
|
536
|
+
return true if change.nil? || change["diff"].empty? || change["deleted_file"]
|
537
|
+
|
538
|
+
# If new file then return in range
|
539
|
+
return false if change["new_file"]
|
540
|
+
|
541
|
+
addition_lines = generate_addition_lines(change["diff"])
|
542
|
+
return false if addition_lines.include?(message.line.to_i)
|
543
|
+
|
544
|
+
return true
|
545
|
+
end
|
546
|
+
|
547
|
+
def generate_addition_lines(diff)
|
548
|
+
range_header_regexp = /@@ -(?<old>[0-9]+)(,([0-9]+))? \+(?<new>[0-9]+)(,([0-9]+))? @@.*/
|
549
|
+
addition_lines = []
|
550
|
+
line_number = 0
|
551
|
+
diff.each_line do |line|
|
552
|
+
if line.match range_header_regexp
|
553
|
+
line = line.split('+').last
|
554
|
+
line = line.split(' ').first
|
555
|
+
range_string = line.split(',')
|
556
|
+
line_number = range_string[0].to_i - 1
|
557
|
+
elsif line.start_with?('+')
|
558
|
+
addition_lines.push(line_number)
|
559
|
+
elsif line.start_with?('-')
|
560
|
+
line_number=line_number-1
|
561
|
+
end
|
562
|
+
line_number=line_number+1
|
563
|
+
end
|
564
|
+
addition_lines
|
565
|
+
end
|
566
|
+
|
523
567
|
end
|
524
568
|
end
|
525
569
|
end
|
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: 8.0.
|
4
|
+
version: 8.0.6
|
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: 2020-
|
12
|
+
date: 2020-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|