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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17279e83964586e1eef46c40740b9c0fb839ea85a3c3d367a898c9b664767eca
4
- data.tar.gz: 6afc0eb2cb97f22d988bf56cb0fe48063aa5eab060471cff2d95c0bc8435b3da
3
+ metadata.gz: c1a29ac64cb5013e28a0e137ba85672f035a3116508c15815ff34e2e4c2efe71
4
+ data.tar.gz: ccd8f3bf454de07224648c91fcff6f4e63d8173b50215d769de44230b4621e16
5
5
  SHA512:
6
- metadata.gz: ee7544abd31b5bd6320efdc79668169d0c5bfc0aa873b2d971bdfb043ab08bd3e05149ddc714cbcd98257c7bd0c815e4899afd573c33ff5d815626fdf01c1c01
7
- data.tar.gz: fbe7c247fee1a41cb6e212141896f7282547f91f8ad0b59f36ae18bab2e32783e1b3ff22db1231e30e6bb5d3feaa98aea67099f114eaa9a45e30dc2478d562b0
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
- pr_url = env["LOCAL_GIT_PR_URL"] || env["LOCAL_GIT_MR_URL"]
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: 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") { env.fetch("LOCAL_GIT_MR_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
- (env["LOCAL_GIT_PR_URL"] && !env["LOCAL_GIT_PR_URL"].empty?) ||
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
- # Clean up the slug to remove any trailing dashes or slashes that might be part of the GitLab URL format
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
- scm_provider = find_scm_provider(remote_url)
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
- bitbucket_cloud_client(env)
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
- bitbucket_server_client(env)
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
- vsts_client(env)
158
- when :gitlab
159
- gitlab_client(env)
151
+ require "danger/request_sources/vsts_api"
152
+ RequestSources::VSTSAPI.new(repo_slug, specific_pull_request_id, env)
153
+
160
154
  when :github
161
- github_client(env)
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
@@ -6,7 +6,6 @@ module Danger
6
6
  require "danger/commands/staging"
7
7
  require "danger/commands/systems"
8
8
  require "danger/commands/pr"
9
- require "danger/commands/mr"
10
9
 
11
10
  # manually set claide plugins as a subcommand
12
11
  require "claide_plugin"
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "9.5.2".freeze
2
+ VERSION = "9.5.3".freeze
3
3
  DESCRIPTION = "Like Unit Tests, but for your Team Culture.".freeze
4
4
  end
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.2
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-03 00:00:00.000000000 Z
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
@@ -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