lib/danger/commands/local.rb in danger-0.7.3 vs lib/danger/commands/local.rb in danger-0.7.4
- old
+ new
@@ -3,22 +3,30 @@
self.summary = 'Run the Dangerfile locally.'
self.command = 'local'
def initialize(argv)
@dangerfile_path = "Dangerfile" if File.exist? "Dangerfile"
+ @pr_num = argv.option('use-merged-pr')
super
end
+ def self.options
+ [
+ ['--use-merged-pr=[#id]', 'The ID of an alreadty merged PR inside your history to use as a reference for the local run.']
+ ].concat(super)
+ end
+
def validate!
super
unless @dangerfile_path
help! "Could not find a Dangerfile."
end
end
def run
ENV["DANGER_USE_LOCAL_GIT"] = "YES"
+ ENV["LOCAL_GIT_PR_ID"] = @pr_num if @pr_num
dm = Dangerfile.new
dm.env = EnvironmentManager.new(ENV)
source = dm.env.ci_source
@@ -45,9 +53,10 @@
dm.env.request_source = gh
dm.env.scm = GitRepo.new
+ dm.env.ensure_danger_branches_are_setup
dm.env.scm.diff_for_folder(".", from: dm.env.ci_source.base_commit, to: dm.env.ci_source.head_commit)
dm.parse(Pathname.new(@dangerfile_path))
dm.print_results
end
end