danger 9.5.2 → 9.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/danger/ci_source/local_git_repo.rb +5 -9
- data/lib/danger/ci_source/support/find_repo_info_from_url.rb +1 -3
- data/lib/danger/ci_source/support/pull_request_finder.rb +22 -62
- data/lib/danger/commands/runner.rb +0 -1
- data/lib/danger/version.rb +1 -1
- metadata +2 -3
- data/lib/danger/commands/mr.rb +0 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1a29ac64cb5013e28a0e137ba85672f035a3116508c15815ff34e2e4c2efe71
|
4
|
+
data.tar.gz: ccd8f3bf454de07224648c91fcff6f4e63d8173b50215d769de44230b4621e16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11a8ad39bcfbddb55c4683e7a7852d79ac17f74f5da55dcfabc796ac4b83a5f4b45d2ad5de53cc8bfdb47034c0572d546ff225b021c4420a751c3d9e0cd9962e
|
7
|
+
data.tar.gz: 6dd015355fb17c8bf4a4f79eec81e4e755b1e6eb94268d55809f4146b41367ed474969ce08358e8ef2deb05998af89ec04414ae0caed6407ff28ef24c374452d
|
@@ -38,8 +38,7 @@ module Danger
|
|
38
38
|
Danger::RequestSources::GitHub,
|
39
39
|
Danger::RequestSources::BitbucketServer,
|
40
40
|
Danger::RequestSources::BitbucketCloud,
|
41
|
-
Danger::RequestSources::VSTS
|
42
|
-
Danger::RequestSources::GitLab
|
41
|
+
Danger::RequestSources::VSTS
|
43
42
|
]
|
44
43
|
end
|
45
44
|
|
@@ -75,8 +74,7 @@ module Danger
|
|
75
74
|
|
76
75
|
def find_remote_info(env)
|
77
76
|
if given_pull_request_url?(env)
|
78
|
-
|
79
|
-
FindRepoInfoFromURL.new(pr_url).call
|
77
|
+
FindRepoInfoFromURL.new(env["LOCAL_GIT_PR_URL"]).call
|
80
78
|
else
|
81
79
|
FindRepoInfoFromLogs.new(
|
82
80
|
env["DANGER_GITHUB_HOST"] || "github.com",
|
@@ -87,16 +85,15 @@ module Danger
|
|
87
85
|
|
88
86
|
def find_pull_request(env)
|
89
87
|
if given_pull_request_url?(env)
|
90
|
-
remote_url = env["LOCAL_GIT_PR_URL"] || env["LOCAL_GIT_MR_URL"]
|
91
88
|
PullRequestFinder.new(
|
92
89
|
remote_info.id,
|
93
90
|
remote_info.slug,
|
94
91
|
remote: true,
|
95
|
-
remote_url:
|
92
|
+
remote_url: env["LOCAL_GIT_PR_URL"]
|
96
93
|
).call(env: env)
|
97
94
|
else
|
98
95
|
PullRequestFinder.new(
|
99
|
-
env.fetch("LOCAL_GIT_PR_ID") {
|
96
|
+
env.fetch("LOCAL_GIT_PR_ID") { "" },
|
100
97
|
remote_info.slug,
|
101
98
|
remote: false,
|
102
99
|
git_logs: run_git("log --oneline -1000000")
|
@@ -105,8 +102,7 @@ module Danger
|
|
105
102
|
end
|
106
103
|
|
107
104
|
def given_pull_request_url?(env)
|
108
|
-
|
109
|
-
(env["LOCAL_GIT_MR_URL"] && !env["LOCAL_GIT_MR_URL"].empty?)
|
105
|
+
env["LOCAL_GIT_PR_URL"] && !env["LOCAL_GIT_PR_URL"].empty?
|
110
106
|
end
|
111
107
|
|
112
108
|
def sha
|
@@ -31,9 +31,7 @@ module Danger
|
|
31
31
|
else
|
32
32
|
matched = url.match(REGEXP)
|
33
33
|
if matched
|
34
|
-
|
35
|
-
clean_slug = matched[:slug].gsub(%r{[-/]+$}, "")
|
36
|
-
RepoInfo.new(clean_slug, matched[:id])
|
34
|
+
RepoInfo.new(matched[:slug], matched[:id])
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
@@ -81,12 +81,6 @@ module Danger
|
|
81
81
|
remote_pull_request.head.sha,
|
82
82
|
remote_pull_request.base.sha
|
83
83
|
)
|
84
|
-
when :gitlab
|
85
|
-
RemotePullRequest.new(
|
86
|
-
remote_pull_request.iid.to_s,
|
87
|
-
remote_pull_request.diff_refs.head_sha,
|
88
|
-
remote_pull_request.diff_refs.base_sha
|
89
|
-
)
|
90
84
|
when :vsts
|
91
85
|
RemotePullRequest.new(
|
92
86
|
remote_pull_request[:pullRequestId].to_s,
|
@@ -99,13 +93,7 @@ module Danger
|
|
99
93
|
end
|
100
94
|
|
101
95
|
def find_remote_pull_request(env)
|
102
|
-
|
103
|
-
|
104
|
-
if scm_provider == :gitlab
|
105
|
-
client(env).merge_request(repo_slug, specific_pull_request_id)
|
106
|
-
else
|
107
|
-
client(env).pull_request(repo_slug, specific_pull_request_id)
|
108
|
-
end
|
96
|
+
client(env).pull_request(repo_slug, specific_pull_request_id)
|
109
97
|
end
|
110
98
|
|
111
99
|
def both_present?
|
@@ -150,61 +138,35 @@ module Danger
|
|
150
138
|
|
151
139
|
case scm_provider
|
152
140
|
when :bitbucket_cloud
|
153
|
-
|
141
|
+
require "danger/request_sources/bitbucket_cloud_api"
|
142
|
+
branch_name = ENV["DANGER_BITBUCKET_TARGET_BRANCH"] # Optional env variable (specifying the target branch) to help find the PR.
|
143
|
+
RequestSources::BitbucketCloudAPI.new(repo_slug, specific_pull_request_id, branch_name, env)
|
144
|
+
|
154
145
|
when :bitbucket_server
|
155
|
-
|
146
|
+
require "danger/request_sources/bitbucket_server_api"
|
147
|
+
project, slug = repo_slug.split("/")
|
148
|
+
RequestSources::BitbucketServerAPI.new(project, slug, specific_pull_request_id, env)
|
149
|
+
|
156
150
|
when :vsts
|
157
|
-
|
158
|
-
|
159
|
-
|
151
|
+
require "danger/request_sources/vsts_api"
|
152
|
+
RequestSources::VSTSAPI.new(repo_slug, specific_pull_request_id, env)
|
153
|
+
|
160
154
|
when :github
|
161
|
-
|
155
|
+
require "octokit"
|
156
|
+
access_token = ENV["DANGER_GITHUB_API_TOKEN"]
|
157
|
+
bearer_token = ENV["DANGER_GITHUB_BEARER_TOKEN"]
|
158
|
+
if bearer_token && !bearer_token.empty?
|
159
|
+
Octokit::Client.new(bearer_token: bearer_token, api_endpoint: api_url)
|
160
|
+
elsif access_token && !access_token.empty?
|
161
|
+
Octokit::Client.new(access_token: access_token, api_endpoint: api_url)
|
162
|
+
else
|
163
|
+
raise "No API token given, please provide one using `DANGER_GITHUB_API_TOKEN` or `DANGER_GITHUB_BEARER_TOKEN`"
|
164
|
+
end
|
162
165
|
else
|
163
166
|
raise "SCM provider not supported: #{scm_provider}"
|
164
167
|
end
|
165
168
|
end
|
166
169
|
|
167
|
-
def bitbucket_cloud_client(env)
|
168
|
-
require "danger/request_sources/bitbucket_cloud_api"
|
169
|
-
branch_name = ENV["DANGER_BITBUCKET_TARGET_BRANCH"] # Optional env variable (specifying the target branch) to help find the PR.
|
170
|
-
RequestSources::BitbucketCloudAPI.new(repo_slug, specific_pull_request_id, branch_name, env)
|
171
|
-
end
|
172
|
-
|
173
|
-
def bitbucket_server_client(env)
|
174
|
-
require "danger/request_sources/bitbucket_server_api"
|
175
|
-
project, slug = repo_slug.split("/")
|
176
|
-
RequestSources::BitbucketServerAPI.new(project, slug, specific_pull_request_id, env)
|
177
|
-
end
|
178
|
-
|
179
|
-
def vsts_client(env)
|
180
|
-
require "danger/request_sources/vsts_api"
|
181
|
-
RequestSources::VSTSAPI.new(repo_slug, specific_pull_request_id, env)
|
182
|
-
end
|
183
|
-
|
184
|
-
def gitlab_client(env)
|
185
|
-
require "gitlab"
|
186
|
-
token = env&.fetch("DANGER_GITLAB_API_TOKEN", nil) || ENV["DANGER_GITLAB_API_TOKEN"]
|
187
|
-
if token && !token.empty?
|
188
|
-
endpoint = env&.fetch("DANGER_GITLAB_API_BASE_URL", nil) || env&.fetch("CI_API_V4_URL", nil) || ENV["DANGER_GITLAB_API_BASE_URL"] || ENV.fetch("CI_API_V4_URL", "https://gitlab.com/api/v4")
|
189
|
-
Gitlab.client(endpoint: endpoint, private_token: token)
|
190
|
-
else
|
191
|
-
raise "No API token given, please provide one using `DANGER_GITLAB_API_TOKEN`"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def github_client(env)
|
196
|
-
require "octokit"
|
197
|
-
access_token = env&.fetch("DANGER_GITHUB_API_TOKEN", nil) || ENV["DANGER_GITHUB_API_TOKEN"]
|
198
|
-
bearer_token = env&.fetch("DANGER_GITHUB_BEARER_TOKEN", nil) || ENV["DANGER_GITHUB_BEARER_TOKEN"]
|
199
|
-
if bearer_token && !bearer_token.empty?
|
200
|
-
Octokit::Client.new(bearer_token: bearer_token, api_endpoint: api_url)
|
201
|
-
elsif access_token && !access_token.empty?
|
202
|
-
Octokit::Client.new(access_token: access_token, api_endpoint: api_url)
|
203
|
-
else
|
204
|
-
raise "No API token given, please provide one using `DANGER_GITHUB_API_TOKEN` or `DANGER_GITHUB_BEARER_TOKEN`"
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
170
|
def api_url
|
209
171
|
ENV.fetch("DANGER_GITHUB_API_HOST") do
|
210
172
|
ENV.fetch("DANGER_GITHUB_API_BASE_URL") do
|
@@ -220,8 +182,6 @@ module Danger
|
|
220
182
|
:bitbucket_server
|
221
183
|
elsif remote_url =~ /\.visualstudio\.com/i || remote_url =~ /dev\.azure\.com/i
|
222
184
|
:vsts
|
223
|
-
elsif remote_url =~ /gitlab\.com/ || remote_url =~ %r{-/merge_requests/}
|
224
|
-
:gitlab
|
225
185
|
else
|
226
186
|
:github
|
227
187
|
end
|
data/lib/danger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.5.
|
4
|
+
version: 9.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orta Therox
|
8
8
|
- Juanito Fatas
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -288,7 +288,6 @@ files:
|
|
288
288
|
- lib/danger/commands/local_helpers/http_cache.rb
|
289
289
|
- lib/danger/commands/local_helpers/local_setup.rb
|
290
290
|
- lib/danger/commands/local_helpers/pry_setup.rb
|
291
|
-
- lib/danger/commands/mr.rb
|
292
291
|
- lib/danger/commands/plugins/plugin_json.rb
|
293
292
|
- lib/danger/commands/plugins/plugin_lint.rb
|
294
293
|
- lib/danger/commands/plugins/plugin_readme.rb
|
data/lib/danger/commands/mr.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "danger/commands/local_helpers/http_cache"
|
4
|
-
require "danger/commands/local_helpers/pry_setup"
|
5
|
-
require "faraday/http_cache"
|
6
|
-
require "fileutils"
|
7
|
-
require "gitlab"
|
8
|
-
require "tmpdir"
|
9
|
-
|
10
|
-
module Danger
|
11
|
-
class MR < Runner
|
12
|
-
self.summary = "Run the Dangerfile locally against GitLab Merge Requests. Does not post to the MR. Usage: danger mr <URL>"
|
13
|
-
self.command = "mr"
|
14
|
-
|
15
|
-
def self.options
|
16
|
-
[
|
17
|
-
["--clear-http-cache", "Clear the local http cache before running Danger locally."],
|
18
|
-
["--pry", "Drop into a Pry shell after evaluating the Dangerfile."],
|
19
|
-
["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"]
|
20
|
-
]
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(argv)
|
24
|
-
show_help = true if argv.arguments == ["-h"]
|
25
|
-
|
26
|
-
@mr_url = argv.shift_argument
|
27
|
-
@clear_http_cache = argv.flag?("clear-http-cache", false)
|
28
|
-
dangerfile = argv.option("dangerfile", "Dangerfile")
|
29
|
-
|
30
|
-
# Currently CLAide doesn't support short option like -h https://github.com/CocoaPods/CLAide/pull/60
|
31
|
-
# when user pass in -h, mimic the behavior of passing in --help.
|
32
|
-
argv = CLAide::ARGV.new ["--help"] if show_help
|
33
|
-
|
34
|
-
super
|
35
|
-
|
36
|
-
@dangerfile_path = dangerfile if File.exist?(dangerfile)
|
37
|
-
|
38
|
-
if argv.flag?("pry", false)
|
39
|
-
@dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path, MR.command)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def validate!
|
44
|
-
super
|
45
|
-
unless @dangerfile_path
|
46
|
-
help! "Could not find a Dangerfile."
|
47
|
-
end
|
48
|
-
unless @mr_url
|
49
|
-
help! "Could not find a merge-request. Usage: danger mr <URL>"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def run
|
54
|
-
ENV["DANGER_USE_LOCAL_GIT"] = "YES"
|
55
|
-
ENV["LOCAL_GIT_MR_URL"] = @mr_url if @mr_url
|
56
|
-
|
57
|
-
configure_gitlab(ENV["DANGER_TMPDIR"] || Dir.tmpdir)
|
58
|
-
|
59
|
-
env = EnvironmentManager.new(ENV, cork)
|
60
|
-
dm = Dangerfile.new(env, cork)
|
61
|
-
|
62
|
-
LocalSetup.new(dm, cork).setup(verbose: verbose) do
|
63
|
-
dm.run(
|
64
|
-
Danger::EnvironmentManager.danger_base_branch,
|
65
|
-
Danger::EnvironmentManager.danger_head_branch,
|
66
|
-
@dangerfile_path,
|
67
|
-
nil,
|
68
|
-
nil,
|
69
|
-
nil,
|
70
|
-
false
|
71
|
-
)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
|
77
|
-
def configure_gitlab(cache_dir)
|
78
|
-
# setup caching for GitLab calls to avoid hitting the API rate limit too quickly
|
79
|
-
cache_file = File.join(cache_dir, "danger_local_gitlab_cache")
|
80
|
-
HTTPCache.new(cache_file, clear_cache: @clear_http_cache)
|
81
|
-
|
82
|
-
# Configure GitLab client
|
83
|
-
Gitlab.configure do |config|
|
84
|
-
config.endpoint = ENV["DANGER_GITLAB_API_BASE_URL"] || ENV.fetch("CI_API_V4_URL", "https://gitlab.com/api/v4")
|
85
|
-
config.private_token = ENV["DANGER_GITLAB_API_TOKEN"]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|