Class: Danger::PR
- Defined in:
- lib/danger/commands/pr.rb
Instance Attribute Summary
Attributes inherited from Runner
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ PR
constructor
A new instance of PR.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ PR
Returns a new instance of PR.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/danger/commands/pr.rb', line 23 def initialize(argv) show_help = true if argv.arguments == ["-h"] @pr_url = argv.shift_argument @clear_http_cache = argv.flag?("clear-http-cache", false) dangerfile = argv.option("dangerfile", "Dangerfile") @verify_ssl = argv.flag?("verify-ssl", true) # Currently CLAide doesn't support short option like -h https://github.com/CocoaPods/CLAide/pull/60 # when user pass in -h, mimic the behavior of passing in --help. argv = CLAide::ARGV.new ["--help"] if show_help super @dangerfile_path = dangerfile if File.exist?(dangerfile) if argv.flag?("pry", false) @dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path, PR.command) end end |
Class Method Details
.options ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/danger/commands/pr.rb', line 14 def self. [ ["--clear-http-cache", "Clear the local http cache before running Danger locally."], ["--pry", "Drop into a Pry shell after evaluating the Dangerfile."], ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"], ["--verify-ssl", "Verify SSL in Octokit"] ] end |
Instance Method Details
#run ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/danger/commands/pr.rb', line 54 def run ENV["DANGER_USE_LOCAL_GIT"] = "YES" ENV["LOCAL_GIT_PR_URL"] = @pr_url if @pr_url configure_octokit(ENV["DANGER_TMPDIR"] || Dir.tmpdir) env = EnvironmentManager.new(ENV, cork) dm = Dangerfile.new(env, cork) LocalSetup.new(dm, cork).setup(verbose: verbose) do dm.run( Danger::EnvironmentManager.danger_base_branch, Danger::EnvironmentManager.danger_head_branch, @dangerfile_path, nil, nil, nil, false ) end end |
#validate! ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/danger/commands/pr.rb', line 44 def validate! super unless @dangerfile_path help! "Could not find a Dangerfile." end unless @pr_url help! "Could not find a pull-request. Usage: danger pr <URL>" end end |