diff --git a/lib/cocoapods-downloader/git.rb b/lib/cocoapods-downloader/git.rb index a247644..526563e 100644 --- a/lib/cocoapods-downloader/git.rb +++ b/lib/cocoapods-downloader/git.rb @@ -5,7 +5,7 @@ module Downloader # class Git < Base def self.options - [:commit, :tag, :branch, :submodules] + [:checkout,:commit, :tag, :branch, :submodules] end def options_specific? @@ -16,6 +16,7 @@ def checkout_options options = {} options[:git] = url options[:commit] = target_git('rev-parse', 'HEAD').chomp + options[:checkout] = target_git_MR() options[:submodules] = true if self.options[:submodules] options end @@ -72,6 +73,7 @@ def self.commit_from_ls_remote(output, branch_name) def download! clone checkout_commit if options[:commit] + target_git_MR if options[:checkout] end # @return [void] Checks out the HEAD of the git source in the destination @@ -165,6 +167,14 @@ def validate_input invalid = input.compact.any? { |value| value.start_with?('--') || value.include?(' --') } raise DownloaderError, "Provided unsafe input for git #{options}." if invalid end + + #Checkout to pull requests with :checkout=>.. + def target_git_MR(*args) + if options[:checkout] + git!(['-C', target_path, 'fetch', 'origin', options[:checkout],'--update-head-ok']) + git!(['-C', target_path, 'checkout', options[:checkout].split("head:")[-1]]) + end + end end end end