Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a danger local command #40

Merged
merged 13 commits into from
Feb 12, 2016
2 changes: 1 addition & 1 deletion lib/danger.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "danger/version"
require "danger/dangerfile"
require "danger/environment_manager"
require "danger/runner"
require "danger/commands/runner"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to make this work like cocoapods, but I'm missing something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CocoaPods shows the sub-commands

~/d/r/l/danger (local_test) ⏛  pod --help
Usage:

    $ pod COMMAND

      CocoaPods, the Cocoa library package manager.

Commands:

    + cache          Manipulate the CocoaPods cache
    + deintegrate    Deintegrate CocoaPods from your project.
    + dependencies   Show project's dependency graph.

Danger doesn't

~/d/r/l/danger (local_test) ⏛  bundle exec danger --help
Usage:

    $ danger COMMAND

      Run the Dangerfile.

Options:

    --version   Show the version of the tool
    --verbose   Show more debugging information

require "danger/init"
require "danger/available_values"

Expand Down
1 change: 1 addition & 0 deletions lib/danger/ci_source/local_git_repo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "ok"
35 changes: 35 additions & 0 deletions lib/danger/commands/local.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Danger
class Local < Runner
self.description = 'Run the Dangerfile locally.'
self.command = 'local'

def initialize(argv)
@dangerfile_path = "Dangerfile" if File.exist? "Dangerfile"
super
end

def validate!
super
unless @dangerfile_path
help! "Could not find a Dangerfile."
end
end

def run
# The order of the following commands is *really* important
dm = Dangerfile.new
dm.env = EnvironmentManager.new(ENV)
dm.env.ci_source =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

dm.env.fill_environment_vars

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than the start of the previous line.
Indent the first line of the right-hand-side of a multi-line assignment.

dm.env.scm.diff_for_folder(".", dm.env.ci_source.base_commit, dm.env.ci_source.head_commit)
dm.parse Pathname.new(@dangerfile_path)

post_results(dm)
end

def post_results(dm)
gh = dm.env.request_source
gh.update_pull_request!(warnings: dm.warnings, errors: dm.errors, messages: dm.messages)
end
end
end
File renamed without changes.