Commit 5e3f797d authored by Sam Stewart's avatar Sam Stewart

[add] ability to specify :branch in Podfiles and Podspecs

parent 326928c7
...@@ -165,6 +165,7 @@ module Pod ...@@ -165,6 +165,7 @@ module Pod
def description def description
"from `#{@params[:git]}'".tap do |description| "from `#{@params[:git]}'".tap do |description|
description << ", commit `#{@params[:commit]}'" if @params[:commit] description << ", commit `#{@params[:commit]}'" if @params[:commit]
description << ", branch `#{@params[:branch]}'" if @params[:branch]
description << ", tag `#{@params[:tag]}'" if @params[:tag] description << ", tag `#{@params[:tag]}'" if @params[:tag]
end end
end end
......
...@@ -14,8 +14,11 @@ module Pod ...@@ -14,8 +14,11 @@ module Pod
def download def download
prepare_cache prepare_cache
puts '->'.green << ' Cloning git repo' if config.verbose? puts '->'.green << ' Cloning git repo' if config.verbose?
# if a branch is specified, it takes priority over a commit
if options[:tag] if options[:tag]
download_tag download_tag
elsif options[:branch]
download_branch
elsif options[:commit] elsif options[:commit]
download_commit download_commit
else else
...@@ -88,6 +91,13 @@ module Pod ...@@ -88,6 +91,13 @@ module Pod
raise Informative, "[!] Cache unable to find git reference `#{ref}' for `#{url}'.".red unless $? == 0 raise Informative, "[!] Cache unable to find git reference `#{ref}' for `#{url}'.".red unless $? == 0
end end
def ensure_remote_branch_exists(branch)
Dir.chdir(cache_path) { git "branch -r | grep #{branch}$" } # check for remote branch and do suffix matching ($ anchor)
return if $? == 0
raise Informative, "[!] Cache unable to find git reference `#{branch}' for `#{url}' (#{$?}).".red
end
def download_head def download_head
update_cache update_cache
git "clone '#{clone_url}' '#{target_path}'" git "clone '#{clone_url}' '#{target_path}'"
...@@ -112,6 +122,16 @@ module Pod ...@@ -112,6 +122,16 @@ module Pod
end end
end end
def download_branch
ensure_remote_branch_exists(options[:branch])
git "clone '#{clone_url}' '#{target_path}'"
Dir.chdir(target_path) do
git "remote add upstream #{@url}" # we need to add the original url, not the cache url
git "fetch -q upstream" # refresh the branches
git "checkout --track -b activated-pod-commit upstream/#{options[:branch]}" # create a new tracking branch
end
end
def clean def clean
(target_path + '.git').rmtree (target_path + '.git').rmtree
end end
...@@ -130,6 +150,8 @@ module Pod ...@@ -130,6 +150,8 @@ module Pod
download_only? ? download_and_extract_tarball(options[:commit]) : super download_only? ? download_and_extract_tarball(options[:commit]) : super
end end
def download_branch
download_only ? download_and_extract_tarball(options[:head]) : super
def clean def clean
if download_only? if download_only?
FileUtils.rm_f(tmp_path) FileUtils.rm_f(tmp_path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment