danger 4.2.1 → 4.2.2
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 +7 -2
- data/lib/danger/ci_source/support/local_pull_request.rb +0 -6
- data/lib/danger/ci_source/support/pull_request_finder.rb +1 -5
- data/lib/danger/commands/local.rb +23 -66
- data/lib/danger/commands/local_helpers/local_setup.rb +41 -0
- data/lib/danger/commands/local_helpers/pry_setup.rb +31 -0
- data/lib/danger/commands/pr.rb +22 -66
- data/lib/danger/commands/runner.rb +1 -1
- data/lib/danger/danger_core/dangerfile.rb +1 -1
- data/lib/danger/helpers/comments_helper.rb +0 -33
- data/lib/danger/helpers/comments_parsing_helper.rb +20 -2
- data/lib/danger/request_sources/github/github.rb +14 -8
- data/lib/danger/request_sources/github/github_review_unsupported.rb +24 -0
- data/lib/danger/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04df75f0e2d2102ce7e9d3024be69a756881b387
|
4
|
+
data.tar.gz: 76f1470a89a64bfb8b068ea8492b0a2f3c73bfa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58f1c840ed23922d7d8124c32e86b95116551b882fd22dccd61576b8cc09055544b03c302cfbf08d98e01ae790ab4152a69d3668f39211c9a9ec6acbf220291a
|
7
|
+
data.tar.gz: 525ee057e14c71dc46e95679c2d62686c6c48a507de94b9ed3202f738f78043d6ef27fc42543f3d69e48dfecff1441194ab7db5fb9f3c9903f56ed928412b179
|
@@ -62,8 +62,13 @@ module Danger
|
|
62
62
|
self.repo_url = self.class.repo_url(env)
|
63
63
|
self.pull_request_id = self.class.pull_request_id(env)
|
64
64
|
|
65
|
-
repo_matches = self.repo_url.match(%r{([\/:])([
|
66
|
-
|
65
|
+
repo_matches = self.repo_url.match(%r{(?:[\/:])projects\/([^\/.]+)\/repos\/([^\/.]+)}) # Bitbucket Server
|
66
|
+
if repo_matches
|
67
|
+
self.repo_slug = "#{repo_matches[1]}/#{repo_matches[2]}"
|
68
|
+
else
|
69
|
+
repo_matches = self.repo_url.match(%r{([\/:])([^\/]+\/[^\/.]+)(?:.git)?$})
|
70
|
+
self.repo_slug = repo_matches[2] unless repo_matches.nil?
|
71
|
+
end
|
67
72
|
end
|
68
73
|
|
69
74
|
def self.pull_request_id(env)
|
@@ -3,8 +3,6 @@ module Danger
|
|
3
3
|
attr_reader :pull_request_id, :sha
|
4
4
|
|
5
5
|
def initialize(log_line)
|
6
|
-
@log_line = log_line
|
7
|
-
|
8
6
|
@pull_request_id = log_line.match(/#(?<id>[0-9]+)/)[:id]
|
9
7
|
@sha = log_line.split(" ".freeze).first
|
10
8
|
end
|
@@ -12,9 +10,5 @@ module Danger
|
|
12
10
|
def valid?
|
13
11
|
pull_request_id && sha
|
14
12
|
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :log_line
|
19
13
|
end
|
20
14
|
end
|
@@ -22,11 +22,7 @@ module Danger
|
|
22
22
|
attr_reader :specific_pull_request_id, :git_logs, :repo_slug, :remote
|
23
23
|
|
24
24
|
def to_boolean(maybe_string)
|
25
|
-
|
26
|
-
true
|
27
|
-
else
|
28
|
-
false
|
29
|
-
end
|
25
|
+
["true", "1", "yes", "y", true].include?(maybe_string)
|
30
26
|
end
|
31
27
|
|
32
28
|
def check_if_any_pull_request!
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require "danger/commands/local_helpers/http_cache"
|
2
|
+
require "danger/commands/local_helpers/local_setup"
|
3
|
+
require "danger/commands/local_helpers/pry_setup"
|
2
4
|
require "faraday/http_cache"
|
3
5
|
require "fileutils"
|
4
6
|
require "octokit"
|
@@ -23,28 +25,9 @@ module Danger
|
|
23
25
|
|
24
26
|
super
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
def should_pry?(argv)
|
30
|
-
argv.flag?("pry", false) && !@dangerfile_path.empty? && validate_pry_available
|
31
|
-
end
|
32
|
-
|
33
|
-
def setup_pry
|
34
|
-
File.delete "_Dangerfile.tmp" if File.exist? "_Dangerfile.tmp"
|
35
|
-
FileUtils.cp @dangerfile_path, "_Dangerfile.tmp"
|
36
|
-
File.open("_Dangerfile.tmp", "a") do |f|
|
37
|
-
f.write("binding.pry; File.delete(\"_Dangerfile.tmp\")")
|
28
|
+
if argv.flag?("pry", false)
|
29
|
+
@dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path)
|
38
30
|
end
|
39
|
-
@dangerfile_path = "_Dangerfile.tmp"
|
40
|
-
end
|
41
|
-
|
42
|
-
def validate_pry_available
|
43
|
-
require "pry"
|
44
|
-
rescue LoadError
|
45
|
-
cork.warn "Pry was not found, and is required for 'danger local --pry'."
|
46
|
-
cork.print_warnings
|
47
|
-
abort
|
48
31
|
end
|
49
32
|
|
50
33
|
def validate!
|
@@ -58,58 +41,32 @@ module Danger
|
|
58
41
|
ENV["DANGER_USE_LOCAL_GIT"] = "YES"
|
59
42
|
ENV["LOCAL_GIT_PR_ID"] = @pr_num if @pr_num
|
60
43
|
|
61
|
-
|
62
|
-
cache_file = File.join(ENV["DANGER_TMPDIR"] || Dir.tmpdir, "danger_local_cache")
|
63
|
-
cache = HTTPCache.new(cache_file, clear_cache: @clear_http_cache)
|
64
|
-
Octokit.middleware = Faraday::RackBuilder.new do |builder|
|
65
|
-
builder.use Faraday::HttpCache, store: cache, serializer: Marshal, shared_cache: false
|
66
|
-
builder.use Octokit::Response::RaiseError
|
67
|
-
builder.adapter Faraday.default_adapter
|
68
|
-
end
|
44
|
+
configure_octokit(ENV["DANGER_TMPDIR"] || Dir.tmpdir)
|
69
45
|
|
70
46
|
env = EnvironmentManager.new(ENV, cork)
|
71
47
|
dm = Dangerfile.new(env, cork)
|
72
|
-
dm.init_plugins
|
73
48
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
49
|
+
LocalSetup.new(dm, cork).setup(verbose: verbose) do
|
50
|
+
dm.run(
|
51
|
+
Danger::EnvironmentManager.danger_base_branch,
|
52
|
+
Danger::EnvironmentManager.danger_head_branch,
|
53
|
+
@dangerfile_path,
|
54
|
+
nil,
|
55
|
+
nil
|
56
|
+
)
|
78
57
|
end
|
58
|
+
end
|
79
59
|
|
80
|
-
|
81
|
-
|
82
|
-
cork.puts "Running your Dangerfile against this PR - https://#{gh.host}/#{source.repo_slug}/pull/#{source.pull_request_id}"
|
83
|
-
|
84
|
-
if verbose != true
|
85
|
-
cork.puts "Turning on --verbose"
|
86
|
-
dm.verbose = true
|
87
|
-
end
|
88
|
-
|
89
|
-
cork.puts
|
90
|
-
|
91
|
-
# We can use tokenless here, as it's running on someone's computer
|
92
|
-
# and is IP locked, as opposed to on the CI.
|
93
|
-
gh.support_tokenless_auth = true
|
94
|
-
|
95
|
-
begin
|
96
|
-
gh.fetch_details
|
97
|
-
rescue Octokit::NotFound
|
98
|
-
cork.puts "Local repository was not found on GitHub. If you're trying to test a private repository please provide a valid API token through " + "DANGER_GITHUB_API_TOKEN".yellow + " environment variable."
|
99
|
-
return
|
100
|
-
end
|
101
|
-
|
102
|
-
dm.env.request_source = gh
|
103
|
-
|
104
|
-
begin
|
105
|
-
dm.env.fill_environment_vars
|
106
|
-
dm.env.ensure_danger_branches_are_setup
|
107
|
-
dm.env.scm.diff_for_folder(".", from: Danger::EnvironmentManager.danger_base_branch, to: Danger::EnvironmentManager.danger_head_branch)
|
60
|
+
private
|
108
61
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
62
|
+
def configure_octokit(cache_dir)
|
63
|
+
# setup caching for Github calls to hitting the API rate limit too quickly
|
64
|
+
cache_file = File.join(cache_dir, "danger_local_cache")
|
65
|
+
cache = HTTPCache.new(cache_file, clear_cache: @clear_http_cache)
|
66
|
+
Octokit.middleware = Faraday::RackBuilder.new do |builder|
|
67
|
+
builder.use Faraday::HttpCache, store: cache, serializer: Marshal, shared_cache: false
|
68
|
+
builder.use Octokit::Response::RaiseError
|
69
|
+
builder.adapter Faraday.default_adapter
|
113
70
|
end
|
114
71
|
end
|
115
72
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Danger
|
2
|
+
class LocalSetup
|
3
|
+
attr_reader :dm, :cork
|
4
|
+
|
5
|
+
def initialize(dangerfile, cork)
|
6
|
+
@dm = dangerfile
|
7
|
+
@cork = cork
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup(verbose: false)
|
11
|
+
source = dm.env.ci_source
|
12
|
+
if source.nil? or source.repo_slug.empty?
|
13
|
+
cork.puts "danger local failed because it only works with GitHub projects at the moment. Sorry.".red
|
14
|
+
exit 0
|
15
|
+
end
|
16
|
+
|
17
|
+
gh = dm.env.request_source
|
18
|
+
# We can use tokenless here, as it's running on someone's computer
|
19
|
+
# and is IP locked, as opposed to on the CI.
|
20
|
+
gh.support_tokenless_auth = true
|
21
|
+
|
22
|
+
cork.puts "Running your Dangerfile against this PR - https://#{gh.host}/#{source.repo_slug}/pull/#{source.pull_request_id}"
|
23
|
+
|
24
|
+
unless verbose
|
25
|
+
cork.puts "Turning on --verbose"
|
26
|
+
dm.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
cork.puts
|
30
|
+
|
31
|
+
begin
|
32
|
+
gh.fetch_details
|
33
|
+
rescue Octokit::NotFound
|
34
|
+
cork.puts "Local repository was not found on GitHub. If you're trying to test a private repository please provide a valid API token through " + "DANGER_GITHUB_API_TOKEN".yellow + " environment variable."
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Danger
|
2
|
+
class PrySetup
|
3
|
+
def initialize(cork)
|
4
|
+
@cork = cork
|
5
|
+
end
|
6
|
+
|
7
|
+
def setup_pry(dangerfile_path)
|
8
|
+
return dangerfile_path if dangerfile_path.empty?
|
9
|
+
validate_pry_available
|
10
|
+
FileUtils.cp dangerfile_path, DANGERFILE_COPY
|
11
|
+
File.open(DANGERFILE_COPY, "a") do |f|
|
12
|
+
f.write("binding.pry; File.delete(\"#{DANGERFILE_COPY}\")")
|
13
|
+
end
|
14
|
+
DANGERFILE_COPY
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :cork
|
20
|
+
|
21
|
+
DANGERFILE_COPY = "_Dangerfile.tmp".freeze
|
22
|
+
|
23
|
+
def validate_pry_available
|
24
|
+
Kernel.require "pry"
|
25
|
+
rescue LoadError
|
26
|
+
cork.warn "Pry was not found, and is required for 'danger pr --pry'."
|
27
|
+
cork.print_warnings
|
28
|
+
abort
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/danger/commands/pr.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "danger/commands/local_helpers/http_cache"
|
2
|
+
require "danger/commands/local_helpers/pry_setup"
|
2
3
|
require "faraday/http_cache"
|
3
4
|
require "fileutils"
|
4
5
|
require "octokit"
|
@@ -26,28 +27,9 @@ module Danger
|
|
26
27
|
|
27
28
|
@dangerfile_path = dangerfile if File.exist?(dangerfile)
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def should_pry?(argv)
|
33
|
-
argv.flag?("pry", false) && !@dangerfile_path.empty? && validate_pry_available
|
34
|
-
end
|
35
|
-
|
36
|
-
def setup_pry
|
37
|
-
File.delete "_Dangerfile.tmp" if File.exist? "_Dangerfile.tmp"
|
38
|
-
FileUtils.cp @dangerfile_path, "_Dangerfile.tmp"
|
39
|
-
File.open("_Dangerfile.tmp", "a") do |f|
|
40
|
-
f.write("binding.pry; File.delete(\"_Dangerfile.tmp\")")
|
30
|
+
if argv.flag?("pry", false)
|
31
|
+
@dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path)
|
41
32
|
end
|
42
|
-
@dangerfile_path = "_Dangerfile.tmp"
|
43
|
-
end
|
44
|
-
|
45
|
-
def validate_pry_available
|
46
|
-
require "pry"
|
47
|
-
rescue LoadError
|
48
|
-
cork.warn "Pry was not found, and is required for 'danger pr --pry'."
|
49
|
-
cork.print_warnings
|
50
|
-
abort
|
51
33
|
end
|
52
34
|
|
53
35
|
def validate!
|
@@ -61,58 +43,32 @@ module Danger
|
|
61
43
|
ENV["DANGER_USE_LOCAL_GIT"] = "YES"
|
62
44
|
ENV["LOCAL_GIT_PR_URL"] = @pr_url if @pr_url
|
63
45
|
|
64
|
-
|
65
|
-
cache_file = File.join(ENV["DANGER_TMPDIR"] || Dir.tmpdir, "danger_local_cache")
|
66
|
-
cache = HTTPCache.new(cache_file, clear_cache: @clear_http_cache)
|
67
|
-
Octokit.middleware = Faraday::RackBuilder.new do |builder|
|
68
|
-
builder.use Faraday::HttpCache, store: cache, serializer: Marshal, shared_cache: false
|
69
|
-
builder.use Octokit::Response::RaiseError
|
70
|
-
builder.adapter Faraday.default_adapter
|
71
|
-
end
|
46
|
+
configure_octokit(ENV["DANGER_TMPDIR"] || Dir.tmpdir)
|
72
47
|
|
73
48
|
env = EnvironmentManager.new(ENV, cork)
|
74
49
|
dm = Dangerfile.new(env, cork)
|
75
|
-
dm.init_plugins
|
76
50
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
51
|
+
LocalSetup.new(dm, cork).setup(verbose: verbose) do
|
52
|
+
dm.run(
|
53
|
+
Danger::EnvironmentManager.danger_base_branch,
|
54
|
+
Danger::EnvironmentManager.danger_head_branch,
|
55
|
+
@dangerfile_path,
|
56
|
+
nil,
|
57
|
+
nil
|
58
|
+
)
|
81
59
|
end
|
60
|
+
end
|
82
61
|
|
83
|
-
|
84
|
-
|
85
|
-
cork.puts "Running your Dangerfile against this PR - https://#{gh.host}/#{source.repo_slug}/pull/#{source.pull_request_id}"
|
86
|
-
|
87
|
-
if verbose != true
|
88
|
-
cork.puts "Turning on --verbose"
|
89
|
-
dm.verbose = true
|
90
|
-
end
|
91
|
-
|
92
|
-
cork.puts
|
93
|
-
|
94
|
-
# We can use tokenless here, as it's running on someone's computer
|
95
|
-
# and is IP locked, as opposed to on the CI.
|
96
|
-
gh.support_tokenless_auth = true
|
97
|
-
|
98
|
-
begin
|
99
|
-
gh.fetch_details
|
100
|
-
rescue Octokit::NotFound
|
101
|
-
cork.puts "Local repository was not found on GitHub. If you're trying to test a private repository please provide a valid API token through " + "DANGER_GITHUB_API_TOKEN".yellow + " environment variable."
|
102
|
-
return
|
103
|
-
end
|
104
|
-
|
105
|
-
dm.env.request_source = gh
|
106
|
-
|
107
|
-
begin
|
108
|
-
dm.env.fill_environment_vars
|
109
|
-
dm.env.ensure_danger_branches_are_setup
|
110
|
-
dm.env.scm.diff_for_folder(".", from: Danger::EnvironmentManager.danger_base_branch, to: Danger::EnvironmentManager.danger_head_branch)
|
62
|
+
private
|
111
63
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
64
|
+
def configure_octokit(cache_dir)
|
65
|
+
# setup caching for Github calls to hitting the API rate limit too quickly
|
66
|
+
cache_file = File.join(cache_dir, "danger_local_cache")
|
67
|
+
cache = HTTPCache.new(cache_file, clear_cache: @clear_http_cache)
|
68
|
+
Octokit.middleware = Faraday::RackBuilder.new do |builder|
|
69
|
+
builder.use Faraday::HttpCache, store: cache, serializer: Marshal, shared_cache: false
|
70
|
+
builder.use Octokit::Response::RaiseError
|
71
|
+
builder.adapter Faraday.default_adapter
|
116
72
|
end
|
117
73
|
end
|
118
74
|
end
|
@@ -58,7 +58,7 @@ module Danger
|
|
58
58
|
["--fail-on-errors=<true|false>", "Should always fail the build process, defaults to false"],
|
59
59
|
["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
|
60
60
|
["--danger_id=<id>", "The identifier of this Danger instance"],
|
61
|
-
["--new-comment", "Makes Danger post a new comment instead of editing
|
61
|
+
["--new-comment", "Makes Danger post a new comment instead of editing its previous one"]
|
62
62
|
].concat(super)
|
63
63
|
end
|
64
64
|
|
@@ -274,7 +274,7 @@ module Danger
|
|
274
274
|
# Push results to the API
|
275
275
|
# Pass along the details of the run to the request source
|
276
276
|
# to send back to the code review site.
|
277
|
-
post_results(danger_id, new_comment)
|
277
|
+
post_results(danger_id, new_comment) unless danger_id.nil?
|
278
278
|
|
279
279
|
# Print results in the terminal
|
280
280
|
print_results
|
@@ -3,8 +3,6 @@ require "danger/helpers/comments_parsing_helper"
|
|
3
3
|
require "danger/helpers/emoji_mapper"
|
4
4
|
require "danger/helpers/find_max_num_violations"
|
5
5
|
|
6
|
-
# rubocop:disable Metrics/ModuleLength
|
7
|
-
|
8
6
|
module Danger
|
9
7
|
module Helpers
|
10
8
|
module CommentsHelper
|
@@ -56,22 +54,6 @@ module Danger
|
|
56
54
|
Violation.new(html, violation.sticky, violation.file, violation.line)
|
57
55
|
end
|
58
56
|
|
59
|
-
def parse_comment(comment)
|
60
|
-
tables = parse_tables_from_comment(comment)
|
61
|
-
violations = {}
|
62
|
-
tables.each do |table|
|
63
|
-
match = danger_table?(table)
|
64
|
-
next unless match
|
65
|
-
title = match[1]
|
66
|
-
kind = table_kind_from_title(title)
|
67
|
-
next unless kind
|
68
|
-
|
69
|
-
violations[kind] = violations_from_table(table)
|
70
|
-
end
|
71
|
-
|
72
|
-
violations.reject { |_, v| v.empty? }
|
73
|
-
end
|
74
|
-
|
75
57
|
def table(name, emoji, violations, all_previous_violations, template: "github")
|
76
58
|
content = violations
|
77
59
|
content = content.map { |v| process_markdown(v) } unless template == "bitbucket_server"
|
@@ -157,21 +139,6 @@ module Danger
|
|
157
139
|
|
158
140
|
private
|
159
141
|
|
160
|
-
GITHUB_OLD_REGEX = %r{<th width="100%"(.*?)</th>}im
|
161
|
-
NEW_REGEX = %r{<th.*data-danger-table="true"(.*?)</th>}im
|
162
|
-
|
163
|
-
def danger_table?(table)
|
164
|
-
# The old GitHub specific method relied on
|
165
|
-
# the width of a `th` element to find the table
|
166
|
-
# title and determine if it was a danger table.
|
167
|
-
# The new method uses a more robust data-danger-table
|
168
|
-
# tag instead.
|
169
|
-
match = GITHUB_OLD_REGEX.match(table)
|
170
|
-
return match if match
|
171
|
-
|
172
|
-
return NEW_REGEX.match(table)
|
173
|
-
end
|
174
|
-
|
175
142
|
def pluralize(string, count)
|
176
143
|
string.danger_pluralize(count)
|
177
144
|
end
|
@@ -27,8 +27,9 @@ module Danger
|
|
27
27
|
tables = parse_tables_from_comment(comment)
|
28
28
|
violations = {}
|
29
29
|
tables.each do |table|
|
30
|
-
|
31
|
-
|
30
|
+
match = danger_table?(table)
|
31
|
+
next unless match
|
32
|
+
title = match[1]
|
32
33
|
kind = table_kind_from_title(title)
|
33
34
|
next unless kind
|
34
35
|
|
@@ -47,6 +48,23 @@ module Danger
|
|
47
48
|
:message
|
48
49
|
end
|
49
50
|
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
GITHUB_OLD_REGEX = %r{<th width="100%"(.*?)</th>}im
|
55
|
+
NEW_REGEX = %r{<th.*data-danger-table="true"(.*?)</th>}im
|
56
|
+
|
57
|
+
def danger_table?(table)
|
58
|
+
# The old GitHub specific method relied on
|
59
|
+
# the width of a `th` element to find the table
|
60
|
+
# title and determine if it was a danger table.
|
61
|
+
# The new method uses a more robust data-danger-table
|
62
|
+
# tag instead.
|
63
|
+
match = GITHUB_OLD_REGEX.match(table)
|
64
|
+
return match if match
|
65
|
+
|
66
|
+
return NEW_REGEX.match(table)
|
67
|
+
end
|
50
68
|
end
|
51
69
|
end
|
52
70
|
end
|
@@ -3,7 +3,8 @@ require "octokit"
|
|
3
3
|
require "danger/helpers/comments_helper"
|
4
4
|
require "danger/helpers/comment"
|
5
5
|
require "danger/request_sources/github/github_review"
|
6
|
-
require "danger/request_sources/github/
|
6
|
+
require "danger/request_sources/github/github_review_unsupported"
|
7
|
+
require "danger/request_sources/github/octokit_pr_review"
|
7
8
|
require "danger/request_sources/support/get_ignored_violation"
|
8
9
|
|
9
10
|
module Danger
|
@@ -66,12 +67,17 @@ module Danger
|
|
66
67
|
|
67
68
|
def review
|
68
69
|
return @review unless @review.nil?
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
begin
|
71
|
+
@review = client.pull_request_reviews(ci_source.repo_slug, ci_source.pull_request_id)
|
72
|
+
.map { |review_json| Danger::RequestSources::GitHubSource::Review.new(client, ci_source, review_json) }
|
73
|
+
.select(&:generated_by_danger?)
|
74
|
+
.last
|
75
|
+
@review ||= Danger::RequestSources::GitHubSource::Review.new(client, ci_source)
|
76
|
+
@review
|
77
|
+
rescue Octokit::NotFound
|
78
|
+
@review = Danger::RequestSources::GitHubSource::ReviewUnsupported.new
|
79
|
+
@review
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
def setup_danger_branches
|
@@ -230,7 +236,7 @@ module Danger
|
|
230
236
|
|
231
237
|
diff_lines = self.pr_diff.lines
|
232
238
|
pr_comments = client.pull_request_comments(ci_source.repo_slug, ci_source.pull_request_id)
|
233
|
-
danger_comments = pr_comments.select { |comment| comment
|
239
|
+
danger_comments = pr_comments.select { |comment| Comment.from_github(comment).generated_by_danger?(danger_id) }
|
234
240
|
non_danger_comments = pr_comments - danger_comments
|
235
241
|
|
236
242
|
submit_inline_comments_for_kind!("warning", warnings, diff_lines, danger_comments, previous_violations["warning"], danger_id: danger_id)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module Danger
|
3
|
+
module RequestSources
|
4
|
+
module GitHubSource
|
5
|
+
class ReviewUnsupported
|
6
|
+
attr_reader :id, :body, :status, :review_json
|
7
|
+
|
8
|
+
def initialize; end
|
9
|
+
|
10
|
+
def start; end
|
11
|
+
|
12
|
+
def submit; end
|
13
|
+
|
14
|
+
def message(message, sticky = true, file = nil, line = nil); end
|
15
|
+
|
16
|
+
def warn(message, sticky = true, file = nil, line = nil); end
|
17
|
+
|
18
|
+
def fail(message, sticky = true, file = nil, line = nil); end
|
19
|
+
|
20
|
+
def markdown(message, file = nil, line = nil); end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
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: 4.2.
|
4
|
+
version: 4.2.2
|
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-02-
|
12
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|
@@ -391,6 +391,8 @@ files:
|
|
391
391
|
- lib/danger/commands/init_helpers/interviewer.rb
|
392
392
|
- lib/danger/commands/local.rb
|
393
393
|
- lib/danger/commands/local_helpers/http_cache.rb
|
394
|
+
- lib/danger/commands/local_helpers/local_setup.rb
|
395
|
+
- lib/danger/commands/local_helpers/pry_setup.rb
|
394
396
|
- lib/danger/commands/plugins/plugin_json.rb
|
395
397
|
- lib/danger/commands/plugins/plugin_lint.rb
|
396
398
|
- lib/danger/commands/plugins/plugin_readme.rb
|
@@ -436,6 +438,7 @@ files:
|
|
436
438
|
- lib/danger/request_sources/github/github.rb
|
437
439
|
- lib/danger/request_sources/github/github_review.rb
|
438
440
|
- lib/danger/request_sources/github/github_review_resolver.rb
|
441
|
+
- lib/danger/request_sources/github/github_review_unsupported.rb
|
439
442
|
- lib/danger/request_sources/github/octokit_pr_review.rb
|
440
443
|
- lib/danger/request_sources/gitlab.rb
|
441
444
|
- lib/danger/request_sources/request_source.rb
|