From 72889ea6a8c1834a6e4e96c78ba8ed97ff26f059 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 27 Jul 2011 12:51:16 +0100 Subject: [PATCH] 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. --- Library/Homebrew/download_strategy.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 616f5f65c7..883e81a053 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -296,9 +296,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy end def fetch - raise "You must install Git:\n\n"+ - " brew install git\n" \ - unless system "/usr/bin/which git" + raise "You must install Git: brew install git" unless system "/usr/bin/which -s git" ohai "Cloning #{@url}" @@ -321,7 +319,8 @@ class GitDownloadStrategy < AbstractDownloadStrategy else puts "Updating #{@clone}" 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. quiet_safe_system 'git', 'fetch', '--tags' if @spec == :tag end