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

Checkout to PullRequest commits for pod #129

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/cocoapods-downloader/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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