danger 8.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +94 -0
  4. data/bin/danger +5 -0
  5. data/lib/assets/DangerfileTemplate +13 -0
  6. data/lib/danger.rb +44 -0
  7. data/lib/danger/ci_source/appcenter.rb +55 -0
  8. data/lib/danger/ci_source/appveyor.rb +60 -0
  9. data/lib/danger/ci_source/azure_pipelines.rb +44 -0
  10. data/lib/danger/ci_source/bamboo.rb +41 -0
  11. data/lib/danger/ci_source/bitbucket_pipelines.rb +37 -0
  12. data/lib/danger/ci_source/bitrise.rb +65 -0
  13. data/lib/danger/ci_source/buddybuild.rb +62 -0
  14. data/lib/danger/ci_source/buildkite.rb +51 -0
  15. data/lib/danger/ci_source/ci_source.rb +37 -0
  16. data/lib/danger/ci_source/circle.rb +94 -0
  17. data/lib/danger/ci_source/circle_api.rb +51 -0
  18. data/lib/danger/ci_source/cirrus.rb +31 -0
  19. data/lib/danger/ci_source/code_build.rb +57 -0
  20. data/lib/danger/ci_source/codefresh.rb +53 -0
  21. data/lib/danger/ci_source/codeship.rb +44 -0
  22. data/lib/danger/ci_source/dotci.rb +52 -0
  23. data/lib/danger/ci_source/drone.rb +71 -0
  24. data/lib/danger/ci_source/github_actions.rb +43 -0
  25. data/lib/danger/ci_source/gitlab_ci.rb +86 -0
  26. data/lib/danger/ci_source/jenkins.rb +149 -0
  27. data/lib/danger/ci_source/local_git_repo.rb +119 -0
  28. data/lib/danger/ci_source/local_only_git_repo.rb +47 -0
  29. data/lib/danger/ci_source/screwdriver.rb +47 -0
  30. data/lib/danger/ci_source/semaphore.rb +37 -0
  31. data/lib/danger/ci_source/support/commits.rb +17 -0
  32. data/lib/danger/ci_source/support/find_repo_info_from_logs.rb +35 -0
  33. data/lib/danger/ci_source/support/find_repo_info_from_url.rb +42 -0
  34. data/lib/danger/ci_source/support/local_pull_request.rb +14 -0
  35. data/lib/danger/ci_source/support/no_pull_request.rb +7 -0
  36. data/lib/danger/ci_source/support/no_repo_info.rb +5 -0
  37. data/lib/danger/ci_source/support/pull_request_finder.rb +179 -0
  38. data/lib/danger/ci_source/support/remote_pull_request.rb +15 -0
  39. data/lib/danger/ci_source/support/repo_info.rb +10 -0
  40. data/lib/danger/ci_source/surf.rb +37 -0
  41. data/lib/danger/ci_source/teamcity.rb +159 -0
  42. data/lib/danger/ci_source/travis.rb +51 -0
  43. data/lib/danger/ci_source/vsts.rb +73 -0
  44. data/lib/danger/ci_source/xcode_server.rb +48 -0
  45. data/lib/danger/clients/rubygems_client.rb +14 -0
  46. data/lib/danger/commands/dangerfile/gem.rb +43 -0
  47. data/lib/danger/commands/dangerfile/init.rb +30 -0
  48. data/lib/danger/commands/dry_run.rb +54 -0
  49. data/lib/danger/commands/init.rb +297 -0
  50. data/lib/danger/commands/init_helpers/interviewer.rb +92 -0
  51. data/lib/danger/commands/local.rb +83 -0
  52. data/lib/danger/commands/local_helpers/http_cache.rb +36 -0
  53. data/lib/danger/commands/local_helpers/local_setup.rb +46 -0
  54. data/lib/danger/commands/local_helpers/pry_setup.rb +31 -0
  55. data/lib/danger/commands/plugins/plugin_json.rb +46 -0
  56. data/lib/danger/commands/plugins/plugin_lint.rb +54 -0
  57. data/lib/danger/commands/plugins/plugin_readme.rb +45 -0
  58. data/lib/danger/commands/pr.rb +92 -0
  59. data/lib/danger/commands/runner.rb +94 -0
  60. data/lib/danger/commands/staging.rb +53 -0
  61. data/lib/danger/commands/systems.rb +43 -0
  62. data/lib/danger/comment_generators/bitbucket_server.md.erb +20 -0
  63. data/lib/danger/comment_generators/bitbucket_server_inline.md.erb +15 -0
  64. data/lib/danger/comment_generators/bitbucket_server_message_group.md.erb +12 -0
  65. data/lib/danger/comment_generators/github.md.erb +55 -0
  66. data/lib/danger/comment_generators/github_inline.md.erb +26 -0
  67. data/lib/danger/comment_generators/gitlab.md.erb +40 -0
  68. data/lib/danger/comment_generators/gitlab_inline.md.erb +26 -0
  69. data/lib/danger/comment_generators/vsts.md.erb +20 -0
  70. data/lib/danger/core_ext/file_list.rb +18 -0
  71. data/lib/danger/core_ext/string.rb +20 -0
  72. data/lib/danger/danger_core/dangerfile.rb +341 -0
  73. data/lib/danger/danger_core/dangerfile_dsl.rb +29 -0
  74. data/lib/danger/danger_core/dangerfile_generator.rb +11 -0
  75. data/lib/danger/danger_core/environment_manager.rb +123 -0
  76. data/lib/danger/danger_core/executor.rb +92 -0
  77. data/lib/danger/danger_core/message_aggregator.rb +49 -0
  78. data/lib/danger/danger_core/message_group.rb +68 -0
  79. data/lib/danger/danger_core/messages/base.rb +56 -0
  80. data/lib/danger/danger_core/messages/markdown.rb +42 -0
  81. data/lib/danger/danger_core/messages/violation.rb +54 -0
  82. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb +144 -0
  83. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_server_plugin.rb +211 -0
  84. data/lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb +248 -0
  85. data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +158 -0
  86. data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +254 -0
  87. data/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin.rb +240 -0
  88. data/lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb +42 -0
  89. data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +218 -0
  90. data/lib/danger/danger_core/plugins/dangerfile_vsts_plugin.rb +191 -0
  91. data/lib/danger/danger_core/standard_error.rb +143 -0
  92. data/lib/danger/helpers/array_subclass.rb +61 -0
  93. data/lib/danger/helpers/comment.rb +32 -0
  94. data/lib/danger/helpers/comments_helper.rb +178 -0
  95. data/lib/danger/helpers/comments_parsing_helper.rb +70 -0
  96. data/lib/danger/helpers/emoji_mapper.rb +41 -0
  97. data/lib/danger/helpers/find_max_num_violations.rb +31 -0
  98. data/lib/danger/helpers/message_groups_array_helper.rb +31 -0
  99. data/lib/danger/plugin_support/gems_resolver.rb +77 -0
  100. data/lib/danger/plugin_support/plugin.rb +49 -0
  101. data/lib/danger/plugin_support/plugin_file_resolver.rb +30 -0
  102. data/lib/danger/plugin_support/plugin_linter.rb +161 -0
  103. data/lib/danger/plugin_support/plugin_parser.rb +199 -0
  104. data/lib/danger/plugin_support/templates/readme_table.html.erb +26 -0
  105. data/lib/danger/request_sources/bitbucket_cloud.rb +171 -0
  106. data/lib/danger/request_sources/bitbucket_cloud_api.rb +181 -0
  107. data/lib/danger/request_sources/bitbucket_server.rb +105 -0
  108. data/lib/danger/request_sources/bitbucket_server_api.rb +117 -0
  109. data/lib/danger/request_sources/github/github.rb +530 -0
  110. data/lib/danger/request_sources/github/github_review.rb +126 -0
  111. data/lib/danger/request_sources/github/github_review_resolver.rb +19 -0
  112. data/lib/danger/request_sources/github/github_review_unsupported.rb +25 -0
  113. data/lib/danger/request_sources/gitlab.rb +525 -0
  114. data/lib/danger/request_sources/local_only.rb +53 -0
  115. data/lib/danger/request_sources/request_source.rb +85 -0
  116. data/lib/danger/request_sources/support/get_ignored_violation.rb +17 -0
  117. data/lib/danger/request_sources/vsts.rb +118 -0
  118. data/lib/danger/request_sources/vsts_api.rb +138 -0
  119. data/lib/danger/scm_source/git_repo.rb +181 -0
  120. data/lib/danger/version.rb +4 -0
  121. metadata +339 -0
@@ -0,0 +1,36 @@
1
+ require "pstore"
2
+
3
+ module Danger
4
+ class HTTPCache
5
+ attr_reader :expires_in
6
+ def initialize(cache_file = nil, options = {})
7
+ File.delete(cache_file) if options[:clear_cache]
8
+ @store = PStore.new(cache_file)
9
+ @expires_in = options[:expires_in] || 300 # 5 minutes
10
+ end
11
+
12
+ def read(key)
13
+ @store.transaction do
14
+ entry = @store[key]
15
+ return nil unless entry
16
+ return entry[:value] unless entry_has_expired(entry, @expires_in)
17
+ @store.delete key
18
+ return nil
19
+ end
20
+ end
21
+
22
+ def delete(key)
23
+ @store.transaction { @store.delete key }
24
+ end
25
+
26
+ def write(key, value)
27
+ @store.transaction do
28
+ @store[key] = { updated_at: Time.now.to_i, value: value }
29
+ end
30
+ end
31
+
32
+ def entry_has_expired(entry, ttl)
33
+ Time.now.to_i > entry[:updated_at].to_i + ttl.to_i
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,46 @@
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 and Bitbucket server projects at the moment. Sorry.".red
14
+ exit 0
15
+ end
16
+ gh = dm.env.request_source
17
+ # We can use tokenless here, as it's running on someone's computer
18
+ # and is IP locked, as opposed to on the CI. Only for Github PRs
19
+ if gh.instance_of? Danger::RequestSources::GitHub
20
+ gh.support_tokenless_auth = true
21
+ end
22
+
23
+ if gh.instance_of? Danger::RequestSources::BitbucketServer
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
+ else
26
+ cork.puts "Running your Dangerfile against this PR - https://#{gh.host}/#{source.repo_slug}/pull/#{source.pull_request_id}"
27
+ end
28
+
29
+ unless verbose
30
+ cork.puts "Turning on --verbose"
31
+ dm.verbose = true
32
+ end
33
+
34
+ cork.puts
35
+
36
+ begin
37
+ gh.fetch_details
38
+ rescue Octokit::NotFound
39
+ 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."
40
+ return
41
+ end
42
+
43
+ yield
44
+ end
45
+ end
46
+ 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("\nbinding.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
@@ -0,0 +1,46 @@
1
+ require "danger/plugin_support/plugin_parser"
2
+ require "danger/plugin_support/plugin_file_resolver"
3
+
4
+ module Danger
5
+ class PluginJSON < CLAide::Command::Plugins
6
+ self.summary = "Prints the JSON documentation representing a plugin"
7
+ self.command = "json"
8
+
9
+ attr_accessor :cork
10
+
11
+ def initialize(argv)
12
+ @refs = argv.arguments! unless argv.arguments.empty?
13
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
14
+ verbose: argv.option("verbose", false))
15
+ super
16
+ end
17
+
18
+ self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
19
+
20
+ self.description = <<-DESC
21
+ Converts a collection of file paths of Danger plugins into a JSON format.
22
+ DESC
23
+
24
+ self.arguments = [
25
+ CLAide::Argument.new("Paths, Gems or Nothing", false, true)
26
+ ]
27
+
28
+ def run
29
+ file_resolver = PluginFileResolver.new(@refs)
30
+ data = file_resolver.resolve
31
+
32
+ parser = PluginParser.new(data[:paths])
33
+ parser.parse
34
+ json = parser.to_json
35
+
36
+ # Append gem metadata into every plugin
37
+ data[:gems].each do |gem_data|
38
+ json.each do |plugin|
39
+ plugin[:gem_metadata] = gem_data if plugin[:gem] == gem_data[:gem]
40
+ end
41
+ end
42
+
43
+ cork.puts json.to_json
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,54 @@
1
+ require "danger/plugin_support/plugin_parser"
2
+ require "danger/plugin_support/plugin_file_resolver"
3
+ require "danger/plugin_support/plugin_linter"
4
+
5
+ module Danger
6
+ class PluginLint < CLAide::Command::Plugins
7
+ self.summary = "Lints a plugin"
8
+ self.command = "lint"
9
+
10
+ attr_accessor :cork
11
+
12
+ def initialize(argv)
13
+ @warnings_as_errors = argv.flag?("warnings-as-errors", false)
14
+ @refs = argv.arguments! unless argv.arguments.empty?
15
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
16
+ verbose: argv.option("verbose", false))
17
+ super
18
+ end
19
+
20
+ self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
21
+
22
+ self.description = <<-DESC
23
+ Converts a collection of file paths of Danger plugins into a JSON format.
24
+ Note: Before 1.0, it will also parse the represented JSON to validate whether https://danger.systems would
25
+ show the plugin on the website.
26
+ DESC
27
+
28
+ self.arguments = [
29
+ CLAide::Argument.new("Paths, Gems or Nothing", false, true)
30
+ ]
31
+
32
+ def self.options
33
+ [
34
+ ["--warnings-as-errors", "Ensure strict linting."]
35
+ ].concat(super)
36
+ end
37
+
38
+ def run
39
+ file_resolver = PluginFileResolver.new(@refs)
40
+ data = file_resolver.resolve
41
+
42
+ parser = PluginParser.new(data[:paths], verbose: true)
43
+ parser.parse
44
+ json = parser.to_json
45
+
46
+ linter = PluginLinter.new(json)
47
+ linter.lint
48
+ linter.print_summary(cork)
49
+
50
+ abort("Failing due to errors\n".red) if linter.failed?
51
+ abort("Failing due to warnings as errors\n".red) if @warnings_as_errors && !linter.warnings.empty?
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,45 @@
1
+ require "danger/plugin_support/plugin_parser"
2
+ require "danger/plugin_support/plugin_file_resolver"
3
+ require "json"
4
+ require "erb"
5
+
6
+ module Danger
7
+ class PluginReadme < CLAide::Command::Plugins
8
+ self.summary = "Generates a README from a set of plugins"
9
+ self.command = "readme"
10
+
11
+ attr_accessor :cork, :json
12
+
13
+ def initialize(argv)
14
+ @refs = argv.arguments! unless argv.arguments.empty?
15
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
16
+ verbose: argv.option("verbose", false))
17
+ super
18
+ end
19
+
20
+ self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
21
+
22
+ self.description = <<-DESC
23
+ Converts a collection of file paths of Danger plugins into a format usable in a README.
24
+ This is useful for Danger itself, but also for any plugins wanting to showcase their API.
25
+ DESC
26
+
27
+ self.arguments = [
28
+ CLAide::Argument.new("Paths, Gems or Nothing", false, true)
29
+ ]
30
+
31
+ attr_accessor :json, :markdown
32
+ def run
33
+ file_resolver = PluginFileResolver.new(@refs)
34
+ data = file_resolver.resolve
35
+
36
+ parser = PluginParser.new(data[:paths])
37
+ parser.parse
38
+
39
+ self.json = JSON.parse(parser.to_json_string)
40
+
41
+ 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)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,92 @@
1
+ require "danger/commands/local_helpers/http_cache"
2
+ require "danger/commands/local_helpers/pry_setup"
3
+ require "faraday/http_cache"
4
+ require "fileutils"
5
+ require "octokit"
6
+ require "tmpdir"
7
+ require "no_proxy_fix"
8
+
9
+ module Danger
10
+ class PR < Runner
11
+ self.summary = "Run the Dangerfile locally against Pull Requests (works with forks, too). Does not post to the PR. Usage: danger pr <URL>".freeze
12
+ self.command = "pr".freeze
13
+
14
+ def self.options
15
+ [
16
+ ["--clear-http-cache", "Clear the local http cache before running Danger locally."],
17
+ ["--pry", "Drop into a Pry shell after evaluating the Dangerfile."],
18
+ ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
19
+ ["--verify-ssl", "Verify SSL in Octokit"]
20
+ ]
21
+ end
22
+
23
+ def initialize(argv)
24
+ show_help = true if argv.arguments == ["-h"]
25
+
26
+ @pr_url = argv.shift_argument
27
+ @clear_http_cache = argv.flag?("clear-http-cache", false)
28
+ dangerfile = argv.option("dangerfile", "Dangerfile")
29
+ @verify_ssl = argv.flag?("verify-ssl", true)
30
+
31
+ # Currently CLAide doesn't support short option like -h https://github.com/CocoaPods/CLAide/pull/60
32
+ # when user pass in -h, mimic the behavior of passing in --help.
33
+ argv = CLAide::ARGV.new ["--help"] if show_help
34
+
35
+ super
36
+
37
+ @dangerfile_path = dangerfile if File.exist?(dangerfile)
38
+
39
+ if argv.flag?("pry", false)
40
+ @dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path)
41
+ end
42
+ end
43
+
44
+ def validate!
45
+ super
46
+ unless @dangerfile_path
47
+ help! "Could not find a Dangerfile."
48
+ end
49
+ unless @pr_url
50
+ help! "Could not find a pull-request. Usage: danger pr <URL>"
51
+ end
52
+ end
53
+
54
+ def run
55
+ ENV["DANGER_USE_LOCAL_GIT"] = "YES"
56
+ ENV["LOCAL_GIT_PR_URL"] = @pr_url if @pr_url
57
+
58
+ configure_octokit(ENV["DANGER_TMPDIR"] || Dir.tmpdir)
59
+
60
+ env = EnvironmentManager.new(ENV, cork)
61
+ dm = Dangerfile.new(env, cork)
62
+
63
+ LocalSetup.new(dm, cork).setup(verbose: verbose) do
64
+ dm.run(
65
+ Danger::EnvironmentManager.danger_base_branch,
66
+ Danger::EnvironmentManager.danger_head_branch,
67
+ @dangerfile_path,
68
+ nil,
69
+ nil,
70
+ nil
71
+ )
72
+ end
73
+ end
74
+
75
+ private
76
+
77
+ def configure_octokit(cache_dir)
78
+ # setup caching for Github calls to hitting the API rate limit too quickly
79
+ cache_file = File.join(cache_dir, "danger_local_cache")
80
+ cache = HTTPCache.new(cache_file, clear_cache: @clear_http_cache)
81
+ Octokit.configure do |config|
82
+ config.connection_options[:ssl] = { verify: @verify_ssl }
83
+ end
84
+ Octokit.middleware = Faraday::RackBuilder.new do |builder|
85
+ builder.use Faraday::HttpCache, store: cache, serializer: Marshal, shared_cache: false
86
+ builder.use Octokit::Middleware::FollowRedirects
87
+ builder.use Octokit::Response::RaiseError
88
+ builder.adapter Faraday.default_adapter
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,94 @@
1
+ module Danger
2
+ class Runner < CLAide::Command
3
+ require "danger/commands/init"
4
+ require "danger/commands/local"
5
+ require "danger/commands/dry_run"
6
+ require "danger/commands/staging"
7
+ require "danger/commands/systems"
8
+ require "danger/commands/pr"
9
+
10
+ # manually set claide plugins as a subcommand
11
+ require "claide_plugin"
12
+ @subcommands << CLAide::Command::Plugins
13
+ CLAide::Plugins.config =
14
+ CLAide::Plugins::Configuration.new(
15
+ "Danger",
16
+ "danger",
17
+ "https://gitlab.com/danger-systems/danger.systems/raw/master/plugins-search-generated.json",
18
+ "https://github.com/danger/danger-plugin-template"
19
+ )
20
+
21
+ require "danger/commands/plugins/plugin_lint"
22
+ require "danger/commands/plugins/plugin_json"
23
+ require "danger/commands/plugins/plugin_readme"
24
+
25
+ require "danger/commands/dangerfile/init"
26
+ require "danger/commands/dangerfile/gem"
27
+
28
+ attr_accessor :cork
29
+
30
+ self.summary = "Run the Dangerfile."
31
+ self.command = "danger"
32
+ self.version = Danger::VERSION
33
+
34
+ self.plugin_prefixes = %w(claide danger)
35
+
36
+ def initialize(argv)
37
+ dangerfile = argv.option("dangerfile", "Dangerfile")
38
+ @dangerfile_path = dangerfile if File.exist?(dangerfile)
39
+ @base = argv.option("base")
40
+ @head = argv.option("head")
41
+ @fail_on_errors = argv.option("fail-on-errors", false)
42
+ @fail_if_no_pr = argv.option("fail-if-no-pr", false)
43
+ @new_comment = argv.flag?("new-comment")
44
+ @remove_previous_comments = argv.flag?("remove-previous-comments")
45
+ @danger_id = argv.option("danger_id", "danger")
46
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
47
+ verbose: argv.option("verbose", false))
48
+ adjust_colored2_output(argv)
49
+ super
50
+ end
51
+
52
+ def validate!
53
+ super
54
+ if self.class == Runner && !@dangerfile_path
55
+ help!("Could not find a Dangerfile.")
56
+ end
57
+ end
58
+
59
+ def self.options
60
+ [
61
+ ["--base=[master|dev|stable]", "A branch/tag/commit to use as the base of the diff"],
62
+ ["--head=[master|dev|stable]", "A branch/tag/commit to use as the head"],
63
+ ["--fail-on-errors=<true|false>", "Should always fail the build process, defaults to false"],
64
+ ["--fail-if-no-pr=<true|false>", "Should fail the build process if no PR is found (useful for CircleCI), defaults to false"],
65
+ ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
66
+ ["--danger_id=<id>", "The identifier of this Danger instance"],
67
+ ["--new-comment", "Makes Danger post a new comment instead of editing its previous one"],
68
+ ["--remove-previous-comments", "Removes all previous comment and create a new one in the end of the list"]
69
+ ].concat(super)
70
+ end
71
+
72
+ def run
73
+ Executor.new(ENV).run(
74
+ base: @base,
75
+ head: @head,
76
+ dangerfile_path: @dangerfile_path,
77
+ danger_id: @danger_id,
78
+ new_comment: @new_comment,
79
+ fail_on_errors: @fail_on_errors,
80
+ fail_if_no_pr: @fail_if_no_pr,
81
+ remove_previous_comments: @remove_previous_comments
82
+ )
83
+ end
84
+
85
+ private
86
+
87
+ def adjust_colored2_output(argv)
88
+ # disable/enable colored2 output
89
+ # consider it execution wide to avoid need to wrap #run and maintain state
90
+ # ARGV#options is non-destructive way to check flags
91
+ Colored2.public_send(argv.options.fetch("ansi", true) ? "enable!" : "disable!")
92
+ end
93
+ end
94
+ end