Class: Danger::Runner
- Inherits:
-
CLAide::Command
- Object
- CLAide::Command
- Danger::Runner
- Defined in:
- lib/danger/commands/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
- #post_results(dm) ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
10 11 12 13 14 15 |
# File 'lib/danger/commands/runner.rb', line 10 def initialize(argv) @dangerfile_path = "Dangerfile" if File.exist? "Dangerfile" @base = argv.option('base') @head = argv.option('head') super end |
Class Method Details
.options ⇒ Object
24 25 26 27 28 29 |
# File 'lib/danger/commands/runner.rb', line 24 def self. [ ['--base=[master|dev|stable]', 'A branch/tag/commit to use as the base of the diff'], ['--head=[master|dev|stable]', 'A branch/tag/commit to use as the head'] ].concat(super) end |
Instance Method Details
#post_results(dm) ⇒ Object
55 56 57 58 |
# File 'lib/danger/commands/runner.rb', line 55 def post_results(dm) gh = dm.env.request_source gh.update_pull_request!(warnings: dm.warnings, errors: dm.errors, messages: dm., markdowns: dm.markdowns) end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/danger/commands/runner.rb', line 31 def run # The order of the following commands is *really* important dm = Dangerfile.new dm.verbose = verbose dm.env = EnvironmentManager.new(ENV) return unless dm.env.ci_source # if it's not a PR dm.env.fill_environment_vars dm.env.ensure_danger_branches_are_setup # Offer the chance for a user to specify a branch through the command line ci_base = @base || dm.env.danger_head_branch ci_head = @head || dm.env.danger_base_branch dm.env.scm.diff_for_folder(".", from: ci_base, to: ci_head) dm.parse Pathname.new(@dangerfile_path) post_results(dm) dm.env.clean_up dm.print_results end |
#validate! ⇒ Object
17 18 19 20 21 22 |
# File 'lib/danger/commands/runner.rb', line 17 def validate! super if self.class == Runner && !@dangerfile_path help! "Could not find a Dangerfile." end end |