danger 8.4.1 → 8.4.4

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: bbecb15ac329fa5977840fe99a41c752b85ecec9669542d0f6002b8f3c374031
4
- data.tar.gz: aa412e3e48efc2fbcac2302b3ce64c960f939c5dbc86a045c5be3d32dfb9df61
3
+ metadata.gz: b6589f95cac1cde709e42711cf14e8b9962af6497276e8f52b8d12d95819de27
4
+ data.tar.gz: d8598e4cd15a64b8210b40a9a0096a98c25e1e5c793fe123c534eb3b19d1be82
5
5
  SHA512:
6
- metadata.gz: adfe653dfe86b47a1ee68b08a69f7b35f0e80979fe4f25725290091aa2fa5ede790331a8bce16f09efd4a1f9690c5df03d17e87516ff6ef6c19514a1d2e00044
7
- data.tar.gz: 23b29baa8b821356398a8802f914019b3327fe2f68285cd1f8bebcef507d2beb0b2ee5259621337d247b4d3c110bc2cd1891dbaf2e9caa3da8e2737250d39499
6
+ metadata.gz: 555b54a82c456622d139464246feb78ac9dec12045910fde3f70a0d54601aff2189a015bf7e69fb554ff7825851903e8b677ad76584307db16c462e1809db678
7
+ data.tar.gz: 50bc63fdefed60b93535c8baa484a48895545eb735656d2672dd4718a92854f24ced6e2ad96267b4570a3137f83d630c591624e166dddbba56a15b2702b9e52c
data/README.md CHANGED
@@ -76,7 +76,7 @@ I'd strongly recommend using `bundle exec guard` to run your tests as you work.
76
76
 
77
77
  #### Debugging
78
78
 
79
- Ruby is super dynamic. One of the best ways to debug Ruby code is by using [pry](http://pryrepl.org/). We include pry for developers: when you have a problem, copy these two lines just before your problem and follow the instructions from "[I Want To Be A Danger Wizard](https://danger.systems/guides/troubleshooting.html#i-want-to-be-a-danger-wizard)."
79
+ Ruby is super dynamic. One of the best ways to debug Ruby code is by using [pry](https://pry.github.io/). We include pry for developers: when you have a problem, copy these two lines just before your problem and follow the instructions from "[I Want To Be A Danger Wizard](https://danger.systems/guides/troubleshooting.html#i-want-to-be-a-danger-wizard)."
80
80
 
81
81
  ```ruby
82
82
  require 'pry'
@@ -66,9 +66,17 @@ module Danger
66
66
  merge_request.nil? ? 0 : merge_request.iid
67
67
  end
68
68
 
69
+ def self.slug_from(env)
70
+ if env["DANGER_PROJECT_REPO_URL"]
71
+ env["DANGER_PROJECT_REPO_URL"].split('/').last(2).join('/')
72
+ else
73
+ env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
74
+ end
75
+ end
76
+
69
77
  def initialize(env)
70
- @env = env
71
- @repo_slug = slug_from(env)
78
+ self.repo_slug = self.class.slug_from(env)
79
+ self.pull_request_id = self.class.determine_pull_or_merge_request_id(env)
72
80
  end
73
81
 
74
82
  def supported_request_sources
@@ -77,19 +85,5 @@ module Danger
77
85
  Danger::RequestSources::GitLab
78
86
  ]
79
87
  end
80
-
81
- def pull_request_id
82
- @pull_request_id ||= self.class.determine_pull_or_merge_request_id(@env)
83
- end
84
-
85
- private
86
-
87
- def slug_from(env)
88
- if env["DANGER_PROJECT_REPO_URL"]
89
- env["DANGER_PROJECT_REPO_URL"].split('/').last(2).join('/')
90
- else
91
- env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
92
- end
93
- end
94
88
  end
95
89
  end
@@ -137,7 +137,7 @@ module Danger
137
137
 
138
138
  def client
139
139
  scm_provider = find_scm_provider(remote_url)
140
-
140
+
141
141
  case scm_provider
142
142
  when :bitbucket_cloud
143
143
  require "danger/request_sources/bitbucket_cloud_api"
@@ -151,8 +151,15 @@ module Danger
151
151
 
152
152
  when :github
153
153
  require "octokit"
154
- Octokit::Client.new(access_token: ENV["DANGER_GITHUB_API_TOKEN"], api_endpoint: api_url)
155
-
154
+ access_token = ENV["DANGER_GITHUB_API_TOKEN"]
155
+ bearer_token = ENV["DANGER_GITHUB_BEARER_TOKEN"]
156
+ if bearer_token && !bearer_token.empty?
157
+ Octokit::Client.new(bearer_token: bearer_token, api_endpoint: api_url)
158
+ elsif access_token && !access_token.empty?
159
+ Octokit::Client.new(access_token: access_token, api_endpoint: api_url)
160
+ else
161
+ raise "No API token given, please provide one using `DANGER_GITHUB_API_TOKEN` or `DANGER_GITHUB_BEARER_TOKEN`"
162
+ end
156
163
  else
157
164
  raise "SCM provider not supported: #{scm_provider}"
158
165
  end
@@ -289,7 +289,7 @@ module Danger
289
289
  # Push results to the API
290
290
  # Pass along the details of the run to the request source
291
291
  # to send back to the code review site.
292
- post_results(danger_id, new_comment, remove_previous_comments) unless danger_id.nil?
292
+ post_results(danger_id, new_comment, remove_previous_comments)
293
293
 
294
294
  # Print results in the terminal
295
295
  print_results
@@ -335,6 +335,9 @@ module Danger
335
335
  end
336
336
 
337
337
  def post_exception(ex, danger_id, new_comment)
338
+ return if ENV["DANGER_DO_NOT_POST_INVALID_DANGERFILE_ERROR"]
339
+ return if danger_id.nil?
340
+
338
341
  env.request_source.update_pull_request!(
339
342
  danger_id: danger_id,
340
343
  new_comment: new_comment,
@@ -148,7 +148,7 @@ module Danger
148
148
  # @return [Boolean]
149
149
  #
150
150
  def pr_draft?
151
- pr_json["mergeable_state"] == "draft"
151
+ pr_json["draft"] == true
152
152
  end
153
153
 
154
154
  # @!group PR Commit Metadata
@@ -19,8 +19,8 @@ module Danger
19
19
  respond_to_method(name, *args, &block)
20
20
  end
21
21
 
22
- def respond_to_missing?(name)
23
- __array__.respond_to?(name) || super
22
+ def respond_to_missing?(name, include_all)
23
+ __array__.respond_to?(name, include_all) || super
24
24
  end
25
25
 
26
26
  def to_a
@@ -17,7 +17,7 @@ module Danger
17
17
  attr_accessor :pr_json, :issue_json, :support_tokenless_auth, :dismiss_out_of_range_messages
18
18
 
19
19
  def self.env_vars
20
- ["DANGER_GITHUB_API_TOKEN"]
20
+ ["DANGER_GITHUB_API_TOKEN", "DANGER_GITHUB_BEARER_TOKEN"]
21
21
  end
22
22
 
23
23
  def self.optional_env_vars
@@ -30,7 +30,8 @@ module Danger
30
30
  self.support_tokenless_auth = false
31
31
  self.dismiss_out_of_range_messages = false
32
32
 
33
- @token = @environment["DANGER_GITHUB_API_TOKEN"]
33
+ @access_token = @environment["DANGER_GITHUB_API_TOKEN"]
34
+ @bearer_token = @environment["DANGER_GITHUB_BEARER_TOKEN"]
34
35
  end
35
36
 
36
37
  def get_pr_from_branch(repo_name, branch_name, owner)
@@ -45,7 +46,7 @@ module Danger
45
46
  end
46
47
 
47
48
  def validates_as_api_source?
48
- (@token && !@token.empty?) || self.environment["DANGER_USE_LOCAL_GIT"]
49
+ valid_bearer_token? || valid_access_token? || self.environment["DANGER_USE_LOCAL_GIT"]
49
50
  end
50
51
 
51
52
  def scm
@@ -72,12 +73,16 @@ module Danger
72
73
  end
73
74
 
74
75
  def client
75
- raise "No API token given, please provide one using `DANGER_GITHUB_API_TOKEN`" if !@token && !support_tokenless_auth
76
+ raise "No API token given, please provide one using `DANGER_GITHUB_API_TOKEN` or `DANGER_GITHUB_BEARER_TOKEN`" if !valid_access_token? && !valid_bearer_token? && !support_tokenless_auth
76
77
  @client ||= begin
77
78
  Octokit.configure do |config|
78
79
  config.connection_options[:ssl] = { verify: verify_ssl }
79
80
  end
80
- Octokit::Client.new(access_token: @token, auto_paginate: true, api_endpoint: api_url)
81
+ if valid_bearer_token?
82
+ Octokit::Client.new(bearer_token: @bearer_token, auto_paginate: true, api_endpoint: api_url)
83
+ elsif valid_access_token?
84
+ Octokit::Client.new(access_token: @access_token, auto_paginate: true, api_endpoint: api_url)
85
+ end
81
86
  end
82
87
  end
83
88
 
@@ -493,6 +498,14 @@ module Danger
493
498
 
494
499
  private
495
500
 
501
+ def valid_access_token?
502
+ @access_token && !@access_token.empty?
503
+ end
504
+
505
+ def valid_bearer_token?
506
+ @bearer_token && !@bearer_token.empty?
507
+ end
508
+
496
509
  def regular_violations_group(warnings: [], errors: [], messages: [], markdowns: [])
497
510
  {
498
511
  warnings: warnings.reject(&:inline?),
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "8.4.1".freeze
2
+ VERSION = "8.4.4".freeze
3
3
  DESCRIPTION = "Like Unit Tests, but for your Team Culture.".freeze
4
4
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.4.1
4
+ version: 8.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orta Therox
8
8
  - Juanito Fatas
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-10-22 00:00:00.000000000 Z
12
+ date: 2022-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide
@@ -327,7 +327,7 @@ homepage: https://github.com/danger/danger
327
327
  licenses:
328
328
  - MIT
329
329
  metadata: {}
330
- post_install_message:
330
+ post_install_message:
331
331
  rdoc_options: []
332
332
  require_paths:
333
333
  - lib
@@ -342,8 +342,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
342
  - !ruby/object:Gem::Version
343
343
  version: '0'
344
344
  requirements: []
345
- rubygems_version: 3.1.2
346
- signing_key:
345
+ rubygems_version: 3.1.4
346
+ signing_key:
347
347
  specification_version: 4
348
348
  summary: Like Unit Tests, but for your Team Culture.
349
349
  test_files: []