Set origin remote URL when updating git clones

Thus the url we use can change.

This only works provided the urls both contain git repos with the same blobs. But this should always be true.
This commit is contained in:
Max Howell 2011-07-27 12:51:16 +01:00
parent f3702b475b
commit 72889ea6a8

View File

@ -296,9 +296,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy
end end
def fetch def fetch
raise "You must install Git:\n\n"+ raise "You must install Git: brew install git" unless system "/usr/bin/which -s git"
" brew install git\n" \
unless system "/usr/bin/which git"
ohai "Cloning #{@url}" ohai "Cloning #{@url}"
@ -321,7 +319,8 @@ class GitDownloadStrategy < AbstractDownloadStrategy
else else
puts "Updating #{@clone}" puts "Updating #{@clone}"
Dir.chdir(@clone) do Dir.chdir(@clone) do
quiet_safe_system 'git', 'fetch', @url safe_system 'git', 'remote', 'set-url', 'origin', @url
quiet_safe_system 'git', 'fetch', 'origin'
# If we're going to checkout a tag, then we need to fetch new tags too. # If we're going to checkout a tag, then we need to fetch new tags too.
quiet_safe_system 'git', 'fetch', '--tags' if @spec == :tag quiet_safe_system 'git', 'fetch', '--tags' if @spec == :tag
end end