danger 9.1.0 → 9.2.0

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/bin/danger +1 -1
  3. data/lib/danger/ci_source/appcircle.rb +71 -71
  4. data/lib/danger/ci_source/appveyor.rb +1 -0
  5. data/lib/danger/ci_source/azure_pipelines.rb +20 -5
  6. data/lib/danger/ci_source/bamboo.rb +1 -1
  7. data/lib/danger/ci_source/bitbucket_pipelines.rb +1 -2
  8. data/lib/danger/ci_source/bitrise.rb +3 -3
  9. data/lib/danger/ci_source/buildkite.rb +1 -1
  10. data/lib/danger/ci_source/circle_api.rb +2 -2
  11. data/lib/danger/ci_source/code_build.rb +1 -1
  12. data/lib/danger/ci_source/codefresh.rb +1 -1
  13. data/lib/danger/ci_source/concourse.rb +4 -5
  14. data/lib/danger/ci_source/dotci.rb +4 -6
  15. data/lib/danger/ci_source/github_actions.rb +6 -6
  16. data/lib/danger/ci_source/gitlab_ci.rb +4 -4
  17. data/lib/danger/ci_source/jenkins.rb +21 -22
  18. data/lib/danger/ci_source/local_git_repo.rb +7 -1
  19. data/lib/danger/ci_source/local_only_git_repo.rb +1 -0
  20. data/lib/danger/ci_source/support/find_repo_info_from_url.rb +11 -10
  21. data/lib/danger/ci_source/support/pull_request_finder.rb +15 -7
  22. data/lib/danger/ci_source/teamcity.rb +1 -1
  23. data/lib/danger/ci_source/xcode_cloud.rb +7 -7
  24. data/lib/danger/commands/init.rb +1 -1
  25. data/lib/danger/commands/local.rb +1 -1
  26. data/lib/danger/commands/local_helpers/http_cache.rb +2 -0
  27. data/lib/danger/commands/local_helpers/local_setup.rb +2 -0
  28. data/lib/danger/commands/local_helpers/pry_setup.rb +1 -0
  29. data/lib/danger/commands/plugins/plugin_json.rb +1 -3
  30. data/lib/danger/commands/plugins/plugin_lint.rb +0 -2
  31. data/lib/danger/commands/plugins/plugin_readme.rb +2 -5
  32. data/lib/danger/commands/runner.rb +1 -1
  33. data/lib/danger/commands/staging.rb +7 -7
  34. data/lib/danger/commands/systems.rb +4 -6
  35. data/lib/danger/core_ext/file_list.rb +2 -2
  36. data/lib/danger/danger_core/dangerfile.rb +13 -13
  37. data/lib/danger/danger_core/environment_manager.rb +2 -1
  38. data/lib/danger/danger_core/executor.rb +10 -11
  39. data/lib/danger/danger_core/message_aggregator.rb +1 -0
  40. data/lib/danger/danger_core/messages/base.rb +1 -0
  41. data/lib/danger/danger_core/messages/markdown.rb +3 -4
  42. data/lib/danger/danger_core/messages/violation.rb +1 -2
  43. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb +1 -3
  44. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_server_plugin.rb +4 -4
  45. data/lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb +8 -2
  46. data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +3 -2
  47. data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +2 -0
  48. data/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin.rb +3 -1
  49. data/lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb +3 -2
  50. data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +3 -1
  51. data/lib/danger/danger_core/plugins/dangerfile_vsts_plugin.rb +3 -3
  52. data/lib/danger/danger_core/standard_error.rb +2 -3
  53. data/lib/danger/helpers/comments_helper.rb +5 -5
  54. data/lib/danger/helpers/comments_parsing_helper.rb +3 -2
  55. data/lib/danger/helpers/emoji_mapper.rb +1 -1
  56. data/lib/danger/plugin_support/plugin.rb +0 -1
  57. data/lib/danger/plugin_support/plugin_linter.rb +1 -0
  58. data/lib/danger/request_sources/bitbucket_cloud.rb +3 -5
  59. data/lib/danger/request_sources/bitbucket_cloud_api.rb +2 -4
  60. data/lib/danger/request_sources/bitbucket_server.rb +10 -13
  61. data/lib/danger/request_sources/bitbucket_server_api.rb +9 -10
  62. data/lib/danger/request_sources/code_insights_api.rb +7 -11
  63. data/lib/danger/request_sources/github/github.rb +15 -14
  64. data/lib/danger/request_sources/github/github_review.rb +3 -2
  65. data/lib/danger/request_sources/github/github_review_resolver.rb +0 -2
  66. data/lib/danger/request_sources/github/github_review_unsupported.rb +0 -2
  67. data/lib/danger/request_sources/gitlab.rb +46 -58
  68. data/lib/danger/request_sources/local_only.rb +0 -2
  69. data/lib/danger/request_sources/request_source.rb +4 -4
  70. data/lib/danger/request_sources/support/get_ignored_violation.rb +1 -1
  71. data/lib/danger/request_sources/vsts.rb +8 -10
  72. data/lib/danger/request_sources/vsts_api.rb +5 -2
  73. data/lib/danger/version.rb +1 -1
  74. data/lib/danger.rb +1 -0
  75. metadata +34 -35
  76. data/lib/danger/ci_source/vsts.rb +0 -73
@@ -155,7 +155,7 @@ module Danger
155
155
  repo_slug = env["BITBUCKET_REPO_SLUG"]
156
156
  begin
157
157
  Danger::RequestSources::BitbucketCloudAPI.new(repo_slug, nil, branch_name, env).pull_request_id
158
- rescue
158
+ rescue StandardError
159
159
  raise "Failed to find a pull request for branch \"#{branch_name}\" on Bitbucket."
160
160
  end
161
161
  end
@@ -1,16 +1,16 @@
1
1
  module Danger
2
2
  # ### CI Setup
3
3
  #
4
- # In order to work with Xcode Cloud and Danger, you will need to add `bundle exec danger` to
4
+ # In order to work with Xcode Cloud and Danger, you will need to add `bundle exec danger` to
5
5
  # the `ci_scripts/ci_post_xcodebuild.sh` (Xcode Cloud's expected filename for a post-action build script).
6
6
  # More details and documentation on Xcode Cloud configuration can be found [here](https://developer.apple.com/documentation/xcode/writing-custom-build-scripts).
7
- #
7
+ #
8
8
  # ### Token Setup
9
9
  #
10
- # You will need to add the `DANGER_GITHUB_API_TOKEN` to your build environment.
11
- # If running on GitHub Enterprise, make sure you also set the expected values for
10
+ # You will need to add the `DANGER_GITHUB_API_TOKEN` to your build environment.
11
+ # If running on GitHub Enterprise, make sure you also set the expected values for
12
12
  # both `DANGER_GITHUB_API_HOST` and `DANGER_GITHUB_HOST`.
13
- #
13
+ #
14
14
  class XcodeCloud < CI
15
15
  def self.validates_as_ci?(env)
16
16
  env.key? "CI_XCODEBUILD_ACTION"
@@ -23,8 +23,8 @@ module Danger
23
23
  def supported_request_sources
24
24
  @supported_request_sources ||= [
25
25
  Danger::RequestSources::GitHub,
26
- Danger::RequestSources::GitLab,
27
- Danger::RequestSources::BitbucketCloud,
26
+ Danger::RequestSources::GitLab,
27
+ Danger::RequestSources::BitbucketCloud,
28
28
  Danger::RequestSources::BitbucketServer
29
29
  ]
30
30
  end
@@ -145,7 +145,7 @@ module Danger
145
145
  def current_repo_slug
146
146
  git = GitRepo.new
147
147
 
148
- author_repo_regexp = %r{(?:[\/:])([^\/]+\/[^\/]+)(?:.git)?$}
148
+ author_repo_regexp = %r{(?:[/:])([^/]+/[^/]+)(?:.git)?$}
149
149
  last_git_regexp = /.git$/
150
150
 
151
151
  matches = git.origins.match(author_repo_regexp)
@@ -66,7 +66,7 @@ module Danger
66
66
 
67
67
  private
68
68
 
69
- # this method is a duplicate of Commands::PR#configure_octokit
69
+ #  this method is a duplicate of Commands::PR#configure_octokit
70
70
  # - worth a refactor sometime?
71
71
  def configure_octokit(cache_dir)
72
72
  # setup caching for Github calls to hitting the API rate limit too quickly
@@ -3,6 +3,7 @@ require "pstore"
3
3
  module Danger
4
4
  class HTTPCache
5
5
  attr_reader :expires_in
6
+
6
7
  def initialize(cache_file = nil, options = {})
7
8
  File.delete(cache_file) if options[:clear_cache]
8
9
  @store = PStore.new(cache_file)
@@ -14,6 +15,7 @@ module Danger
14
15
  entry = @store[key]
15
16
  return nil unless entry
16
17
  return entry[:value] unless entry_has_expired(entry, @expires_in)
18
+
17
19
  @store.delete key
18
20
  return nil
19
21
  end
@@ -22,6 +22,8 @@ module Danger
22
22
 
23
23
  if gh.instance_of? Danger::RequestSources::BitbucketServer
24
24
  cork.puts "Running your Dangerfile against this PR - #{gh.host}/projects/#{source.repo_slug.split('/').first}/repos/#{source.repo_slug.split('/').last}/pull-requests/#{source.pull_request_id}"
25
+ elsif gh.instance_of? Danger::RequestSources::VSTS
26
+ cork.puts "Running your Dangerfile against this PR - #{gh.client.pr_api_endpoint}"
25
27
  else
26
28
  cork.puts "Running your Dangerfile against this PR - https://#{gh.host}/#{source.repo_slug}/pull/#{source.pull_request_id}"
27
29
  end
@@ -6,6 +6,7 @@ module Danger
6
6
 
7
7
  def setup_pry(dangerfile_path, command)
8
8
  return dangerfile_path if dangerfile_path.empty?
9
+
9
10
  validate_pry_available(command)
10
11
  FileUtils.cp dangerfile_path, DANGERFILE_COPY
11
12
  File.open(DANGERFILE_COPY, "a") do |f|
@@ -3,7 +3,7 @@ require "danger/plugin_support/plugin_file_resolver"
3
3
 
4
4
  module Danger
5
5
  class PluginJSON < CLAide::Command::Plugins
6
- self.summary = "Prints the JSON documentation representing a plugin"
6
+ self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
7
7
  self.command = "json"
8
8
 
9
9
  attr_accessor :cork
@@ -15,8 +15,6 @@ module Danger
15
15
  super
16
16
  end
17
17
 
18
- self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
19
-
20
18
  self.description = <<-DESC
21
19
  Converts a collection of file paths of Danger plugins into a JSON format.
22
20
  DESC
@@ -17,8 +17,6 @@ module Danger
17
17
  super
18
18
  end
19
19
 
20
- self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
21
-
22
20
  self.description = <<-DESC
23
21
  Converts a collection of file paths of Danger plugins into a JSON format.
24
22
  Note: Before 1.0, it will also parse the represented JSON to validate whether https://danger.systems would
@@ -8,7 +8,7 @@ module Danger
8
8
  self.summary = "Generates a README from a set of plugins"
9
9
  self.command = "readme"
10
10
 
11
- attr_accessor :cork, :json
11
+ attr_accessor :cork, :json, :markdown
12
12
 
13
13
  def initialize(argv)
14
14
  @refs = argv.arguments! unless argv.arguments.empty?
@@ -17,8 +17,6 @@ module Danger
17
17
  super
18
18
  end
19
19
 
20
- self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
21
-
22
20
  self.description = <<-DESC
23
21
  Converts a collection of file paths of Danger plugins into a format usable in a README.
24
22
  This is useful for Danger itself, but also for any plugins wanting to showcase their API.
@@ -28,7 +26,6 @@ module Danger
28
26
  CLAide::Argument.new("Paths, Gems or Nothing", false, true)
29
27
  ]
30
28
 
31
- attr_accessor :json, :markdown
32
29
  def run
33
30
  file_resolver = PluginFileResolver.new(@refs)
34
31
  data = file_resolver.resolve
@@ -39,7 +36,7 @@ module Danger
39
36
  self.json = JSON.parse(parser.to_json_string)
40
37
 
41
38
  template = File.join(Danger.gem_path, "lib/danger/plugin_support/templates/readme_table.html.erb")
42
- cork.puts ERB.new(File.read(template), 0, "-").result(binding)
39
+ cork.puts ERB.new(File.read(template), trim_mode: "-").result(binding)
43
40
  end
44
41
  end
45
42
  end
@@ -51,7 +51,7 @@ module Danger
51
51
 
52
52
  def validate!
53
53
  super
54
- if self.class == Runner && !@dangerfile_path
54
+ if self.instance_of?(Runner) && !@dangerfile_path
55
55
  help!("Could not find a Dangerfile.")
56
56
  end
57
57
  end
@@ -9,7 +9,7 @@ module Danger
9
9
 
10
10
  def self.options
11
11
  [
12
- ["--pry", "Drop into a Pry shell after evaluating the Dangerfile."]
12
+ ["--pry", "Drop into a Pry shell after evaluating the Dangerfile."]
13
13
  ]
14
14
  end
15
15
 
@@ -41,12 +41,12 @@ module Danger
41
41
  dm = Dangerfile.new(env, cork)
42
42
 
43
43
  dm.run(
44
- Danger::EnvironmentManager.danger_base_branch,
45
- Danger::EnvironmentManager.danger_head_branch,
46
- @dangerfile_path,
47
- nil,
48
- nil,
49
- nil
44
+ Danger::EnvironmentManager.danger_base_branch,
45
+ Danger::EnvironmentManager.danger_head_branch,
46
+ @dangerfile_path,
47
+ nil,
48
+ nil,
49
+ nil
50
50
  )
51
51
  end
52
52
  end
@@ -16,12 +16,10 @@ module Danger
16
16
  require "yard"
17
17
  # Pull out all the Danger::CI subclasses docs
18
18
  registry = YARD::Registry.load(ci_source_paths, true)
19
- ci_sources = begin
20
- registry.all(:class)
21
- .select { |klass| klass.inheritance_tree.map(&:name).include? :CI }
22
- .reject { |source| source.name == :CI }
23
- .reject { |source| source.name == :LocalGitRepo }
24
- end
19
+ ci_sources = registry.all(:class)
20
+ .select { |klass| klass.inheritance_tree.map(&:name).include? :CI }
21
+ .reject { |source| source.name == :CI }
22
+ .reject { |source| source.name == :LocalGitRepo }
25
23
 
26
24
  # Fail if anything is added and not documented
27
25
  cis_without_docs = ci_sources.select { |source| source.base_docstring.empty? }
@@ -8,8 +8,8 @@ module Danger
8
8
  # e.g. "**/something.*" for any file called something with any extension
9
9
  def include?(pattern)
10
10
  self.each do |current|
11
- unless current.nil?
12
- return true if File.fnmatch(pattern, current, File::FNM_EXTGLOB) || pattern == current
11
+ if !current.nil? && (File.fnmatch(pattern, current, File::FNM_EXTGLOB) || pattern == current)
12
+ return true
13
13
  end
14
14
  end
15
15
  return false
@@ -60,7 +60,6 @@ module Danger
60
60
  # When an undefined method is called, we check to see if it's something
61
61
  # that the core DSLs have, then starts looking at plugins support.
62
62
 
63
- # rubocop:disable Style/MethodMissing
64
63
  def method_missing(method_sym, *arguments, **keyword_arguments, &_block)
65
64
  @core_plugins.each do |plugin|
66
65
  if plugin.public_methods(false).include?(method_sym)
@@ -97,6 +96,7 @@ module Danger
97
96
  plugins = Plugin.all_plugins
98
97
  plugins.each do |klass|
99
98
  next if klass.respond_to?(:singleton_class?) && klass.singleton_class?
99
+
100
100
  plugin = klass.new(self)
101
101
  next if plugin.nil? || @plugins[klass]
102
102
 
@@ -115,7 +115,7 @@ module Danger
115
115
  end
116
116
 
117
117
  def external_dsl_attributes
118
- plugins.values.reject { |plugin| @core_plugins.include? plugin } .map { |plugin| { plugin: plugin, methods: plugin.public_methods(false) } }
118
+ plugins.values.reject { |plugin| @core_plugins.include? plugin }.map { |plugin| { plugin: plugin, methods: plugin.public_methods(false) } }
119
119
  end
120
120
 
121
121
  def method_values_for_plugin_hashes(plugin_hashes)
@@ -200,12 +200,12 @@ module Danger
200
200
  self.defined_in_file = path
201
201
  instance_eval do
202
202
  # rubocop:disable Lint/RescueException
203
- begin
204
- eval_file(contents, path)
205
- rescue Exception => e
206
- message = "Invalid `#{path.basename}` file: #{e.message}"
207
- raise DSLError.new(message, path, e.backtrace, contents)
208
- end
203
+
204
+ eval_file(contents, path)
205
+ rescue Exception => e
206
+ message = "Invalid `#{path.basename}` file: #{e.message}"
207
+ raise DSLError.new(message, path, e.backtrace, contents)
208
+
209
209
  # rubocop:enable Lint/RescueException
210
210
  end
211
211
  end
@@ -257,9 +257,9 @@ module Danger
257
257
 
258
258
  if env.request_source.respond_to?(:update_pr_by_line!) && ENV["DANGER_MESSAGE_AGGREGATION"]
259
259
  env.request_source.update_pr_by_line!(message_groups: MessageAggregator.aggregate(**report),
260
- new_comment: new_comment,
261
- remove_previous_comments: remove_previous_comments,
262
- danger_id: report[:danger_id])
260
+ new_comment: new_comment,
261
+ remove_previous_comments: remove_previous_comments,
262
+ danger_id: report[:danger_id])
263
263
  else
264
264
  env.request_source.update_pull_request!(
265
265
  **report,
@@ -293,9 +293,9 @@ module Danger
293
293
 
294
294
  # Print results in the terminal
295
295
  print_results
296
- rescue DSLError => ex
296
+ rescue DSLError => e
297
297
  # Push exception to the API and re-raise
298
- post_exception(ex, danger_id, new_comment) unless danger_id.nil?
298
+ post_exception(e, danger_id, new_comment) unless danger_id.nil?
299
299
  raise
300
300
  ensure
301
301
  # Makes sure that Danger specific git branches are cleaned
@@ -37,6 +37,7 @@ module Danger
37
37
  request_source = klass.new(self.ci_source, env)
38
38
  next unless request_source.validates_as_ci?
39
39
  next unless request_source.validates_as_api_source?
40
+
40
41
  self.request_source = request_source
41
42
  end
42
43
 
@@ -90,7 +91,7 @@ module Danger
90
91
  RequestSources::GitLab
91
92
  elsif repo_url =~ /bitbucket\.(org|com)/i
92
93
  RequestSources::BitbucketCloud
93
- elsif repo_url =~ /dev\.azure\.com/i
94
+ elsif repo_url =~ /\.visualstudio\.com/i || repo_url =~ /dev\.azure\.com/i
94
95
  RequestSources::VSTS
95
96
  end
96
97
  end
@@ -25,16 +25,14 @@ module Danger
25
25
  env ||= EnvironmentManager.new(system_env, cork, danger_id)
26
26
  dm ||= Dangerfile.new(env, cork)
27
27
 
28
- ran_status = begin
29
- dm.run(
30
- base_branch(base),
31
- head_branch(head),
32
- dangerfile_path,
33
- danger_id,
34
- new_comment,
35
- remove_previous_comments
36
- )
37
- end
28
+ ran_status = dm.run(
29
+ base_branch(base),
30
+ head_branch(head),
31
+ dangerfile_path,
32
+ danger_id,
33
+ new_comment,
34
+ remove_previous_comments
35
+ )
38
36
 
39
37
  # By default Danger will use the status API to fail a build,
40
38
  # allowing execution to continue, this behavior isn't always
@@ -85,7 +83,8 @@ module Danger
85
83
  end
86
84
 
87
85
  def commit_request(ci_name)
88
- return "Merge Request" if ci_name == 'GitLabCI'
86
+ return "Merge Request" if ci_name == "GitLabCI"
87
+
89
88
  return "Pull Request"
90
89
  end
91
90
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "danger/danger_core/message_group"
3
4
  require "danger/helpers/message_groups_array_helper"
4
5
 
@@ -21,6 +21,7 @@ module Danger
21
21
 
22
22
  line <=> other.line
23
23
  end
24
+
24
25
  # compares a and b based entirely on whether one or the other is nil
25
26
  # arguments are in the same order as `a <=> b`
26
27
  # nil is sorted earlier - so cmp_nils(nil, 1) => -1
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "danger/danger_core/messages/base"
3
4
 
4
5
  module Danger
5
6
  class Markdown < BaseMessage
6
-
7
7
  def initialize(message, file = nil, line = nil)
8
8
  super(type: :markdown, message: message, file: file, line: line)
9
9
  end
@@ -21,8 +21,7 @@ module Danger
21
21
  h = 1
22
22
  h = h * 31 + message.hash
23
23
  h = h * 17 + file.hash
24
- h = h * 17 + line.hash
25
- h
24
+ h * 17 + line.hash
26
25
  end
27
26
 
28
27
  def to_s
@@ -30,7 +29,7 @@ module Danger
30
29
  extra << "file: #{file}" unless file
31
30
  extra << "line: #{line}" unless line
32
31
 
33
- "Markdown #{message} { #{extra.join ', '.freeze} }"
32
+ "Markdown #{message} { #{extra.join ', '} }"
34
33
  end
35
34
 
36
35
  def <=>(other)
@@ -29,8 +29,7 @@ module Danger
29
29
  h = h * 31 + message.hash
30
30
  h = h * 13 + sticky.hash
31
31
  h = h * 17 + file.hash
32
- h = h * 17 + line.hash
33
- h
32
+ h * 17 + line.hash
34
33
  end
35
34
 
36
35
  def <=>(other)
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require "danger/plugin_support/plugin"
4
2
 
5
3
  module Danger
@@ -52,6 +50,7 @@ module Danger
52
50
  # So that this init can fail.
53
51
  def self.new(dangerfile)
54
52
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::BitbucketCloud
53
+
55
54
  super
56
55
  end
57
56
 
@@ -139,6 +138,5 @@ module Danger
139
138
  def head_commit
140
139
  @bs.pr_json[:source][:commit][:hash]
141
140
  end
142
-
143
141
  end
144
142
  end
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require "danger/plugin_support/plugin"
4
2
 
5
3
  module Danger
@@ -52,6 +50,7 @@ module Danger
52
50
  # So that this init can fail.
53
51
  def self.new(dangerfile)
54
52
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::BitbucketServer
53
+
55
54
  super
56
55
  end
57
56
 
@@ -169,7 +168,7 @@ module Danger
169
168
  def markdown_link(paths, full_path: true)
170
169
  create_link(paths, full_path) { |href, text| create_markdown_link(href, text) }
171
170
  end
172
-
171
+
173
172
  # @!group Bitbucket Server Misc
174
173
  # Updates the PR with build status and build server job link.
175
174
  # @param [String] status
@@ -181,7 +180,7 @@ module Danger
181
180
  # @return [String]
182
181
  #
183
182
  def update_pr_build_status(status, build_job_link, description)
184
- @bs.update_pr_build_status(status, build_job_link, description)
183
+ @bs.update_pr_build_status(status, build_job_link, description)
185
184
  end
186
185
 
187
186
  private
@@ -201,6 +200,7 @@ module Danger
201
200
  end
202
201
 
203
202
  return paths.first if paths.count < 2
203
+
204
204
  paths.first(paths.count - 1).join(", ") + " & " + paths.last
205
205
  end
206
206
 
@@ -74,6 +74,8 @@ module Danger
74
74
  # @option opts [String] :github GitHub repo
75
75
  # @option opts [String] :gitlab GitLab repo
76
76
  # @option opts [String] :gem Gem name
77
+ # @option opts [String] :ref The name of branch, tag or commit
78
+ # @option opts [String] :branch Alias of :ref
77
79
  # @option opts [String] :path Path to Dangerfile
78
80
  # @return [void]
79
81
  def import_dangerfile(opts)
@@ -82,9 +84,9 @@ module Danger
82
84
  import_dangerfile_from_github(opts)
83
85
  elsif opts.kind_of?(Hash)
84
86
  if opts.key?(:github)
85
- import_dangerfile_from_github(opts[:github], opts[:branch], opts[:path])
87
+ import_dangerfile_from_github(opts[:github], opts[:ref] || opts[:branch], opts[:path])
86
88
  elsif opts.key?(:gitlab)
87
- import_dangerfile_from_gitlab(opts[:gitlab], opts[:branch], opts[:path])
89
+ import_dangerfile_from_gitlab(opts[:gitlab], opts[:ref] || opts[:branch], opts[:path])
88
90
  elsif opts.key?(:path)
89
91
  import_dangerfile_from_path(opts[:path])
90
92
  elsif opts.key?(:gem)
@@ -132,6 +134,7 @@ module Danger
132
134
  #
133
135
  def import_dangerfile_from_path(path)
134
136
  raise "`import_dangerfile_from_path` requires a string" unless path.kind_of?(String)
137
+
135
138
  local_path = File.file?(path) ? path : File.join(path, "Dangerfile")
136
139
  @dangerfile.parse(Pathname.new(local_path))
137
140
  end
@@ -145,6 +148,7 @@ module Danger
145
148
  #
146
149
  def import_dangerfile_from_gem(name)
147
150
  raise "`import_dangerfile_from_gem` requires a string" unless name.kind_of?(String)
151
+
148
152
  spec = Gem::Specification.find_by_name(name)
149
153
  import_dangerfile_from_path(spec.gem_dir)
150
154
  rescue Gem::MissingSpecError
@@ -164,6 +168,7 @@ module Danger
164
168
  #
165
169
  def import_dangerfile_from_github(slug, branch = nil, path = nil)
166
170
  raise "`import_dangerfile_from_github` requires a string" unless slug.kind_of?(String)
171
+
167
172
  org, repo = slug.split("/")
168
173
  download_url = env.request_source.file_url(organisation: org, repository: repo, branch: branch, path: path || "Dangerfile")
169
174
  local_path = download(download_url)
@@ -196,6 +201,7 @@ module Danger
196
201
  #
197
202
  def import_dangerfile_from_url(url)
198
203
  raise "`import_dangerfile_from_url` requires a string" unless url.kind_of?(String)
204
+
199
205
  local_path = download(url)
200
206
  @dangerfile.parse(Pathname.new(local_path))
201
207
  end
@@ -22,7 +22,7 @@ module Danger
22
22
  #
23
23
  # @example Warn when there are merge commits in the diff
24
24
  #
25
- # if git.commits.any? { |c| c.message =~ /^Merge branch 'master'/ }
25
+ # if git.commits.any? { |c| c.parents.count > 1 }
26
26
  # warn 'Please rebase to get rid of the merge commits in this PR'
27
27
  # end
28
28
  #
@@ -46,7 +46,7 @@ module Danger
46
46
 
47
47
  def initialize(dangerfile)
48
48
  super(dangerfile)
49
- raise unless dangerfile.env.scm.class == Danger::GitRepo
49
+ raise unless dangerfile.env.scm.class == Danger::GitRepo # rubocop:disable Style/ClassEqualityComparison
50
50
 
51
51
  @git = dangerfile.env.scm
52
52
  end
@@ -137,6 +137,7 @@ module Danger
137
137
  #
138
138
  def info_for_file(file)
139
139
  return nil unless modified_files.include?(file) || added_files.include?(file) || deleted_files.include?(file)
140
+
140
141
  stats = @git.diff.stats[:files][file]
141
142
  diff = @git.diff[file]
142
143
  {
@@ -76,6 +76,7 @@ module Danger
76
76
  # So that this init can fail.
77
77
  def self.new(dangerfile)
78
78
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::GitHub
79
+
79
80
  super
80
81
  end
81
82
 
@@ -229,6 +230,7 @@ module Danger
229
230
  end
230
231
 
231
232
  return paths.first if paths.count < 2
233
+
232
234
  paths.first(paths.count - 1).join(", ") + " & " + paths.last
233
235
  end
234
236
 
@@ -65,7 +65,7 @@ module Danger
65
65
  # message "Reviewer roulete rolled for: #{reviewer.to_hash['name']} (@#{reviewer.to_hash['username']})"
66
66
  # gitlab.api.update_merge_request(project_id, mr_id, { assignee_id: reviewer.to_hash["id"] })
67
67
  # end
68
- #
68
+ #
69
69
  #
70
70
  # @see danger/danger
71
71
  # @tags core, gitlab
@@ -74,6 +74,7 @@ module Danger
74
74
  # So that this init can fail.
75
75
  def self.new(dangerfile)
76
76
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::GitLab
77
+
77
78
  super
78
79
  end
79
80
 
@@ -240,6 +241,7 @@ module Danger
240
241
  end
241
242
 
242
243
  return paths.first if paths.count < 2
244
+
243
245
  paths.first(paths.count - 1).join(", ") + " & " + paths.last
244
246
  end
245
247
 
@@ -6,12 +6,12 @@ module Danger
6
6
  # It is support plugin for dry_run command and does not expose any methods.
7
7
  # But you can still use other plugins like git
8
8
  #
9
- # @example Check that added lines contains agreed form of words
9
+ # @example Check that added lines contains agreed form of words
10
10
  #
11
11
  # git.diff.each do |chunk|
12
12
  # chunk.patch.lines.grep(/^\+/).each do |added_line|
13
13
  # if added_line.gsub!(/(?<cancel>cancel)(?<rest>[^l[[:space:]][[:punct:]]]+)/i, '>>\k<cancel>-l-\k<rest><<')
14
- # fail "Single 'L' for cancellation-alike words in '#{added_line}'"
14
+ # fail "Single 'L' for cancellation-alike words in '#{added_line}'"
15
15
  # end
16
16
  # end
17
17
  # end
@@ -23,6 +23,7 @@ module Danger
23
23
  # So that this init can fail.
24
24
  def self.new(dangerfile)
25
25
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::LocalOnly
26
+
26
27
  super
27
28
  end
28
29
 
@@ -149,6 +149,7 @@ module Danger
149
149
 
150
150
  warnings.flatten.each do |warning|
151
151
  next if should_ignore_violation(warning)
152
+
152
153
  @warnings << Violation.new(warning, sticky, file, line, type: :warning) if warning
153
154
  end
154
155
  end
@@ -174,11 +175,12 @@ module Danger
174
175
 
175
176
  failures.flatten.each do |failure|
176
177
  next if should_ignore_violation(failure)
178
+
177
179
  @errors << Violation.new(failure, sticky, file, line, type: :error) if failure
178
180
  end
179
181
  end
180
182
 
181
- alias_method :failure, :fail
183
+ alias failure fail
182
184
 
183
185
  # @!group Reporting
184
186
  # A list of all messages passed to Danger, including