CocoaPods/CocoaPods — pull request #514 by raylillywhite (2012-09-11 07:03:07+00:00)
Title: Update git repo cache if branch isn't found

This change updates the cached git repo for a pod if the specified branch isn't found. I ran into this when pushing a new branch and changing the referenced branch in my Podfile. Here's the relevant section of my Podfile:

```ruby
pod do |s|
s.name = 'MBProgressHUD-ht-test3'
s.version = '0.4.ht'
s.platform = :ios
s.license = 'MIT'
s.summary = 'An iOS activity indicator view.'
s.homepage = 'https://github.com/matej/MBProgressHUD'
s.author = { 'Matej Bukovinski' => 'matej@bukovinski.com',
'Jonathan George' => 'jonathan@jdg.net' }

s.source = { :git => 'https://github.com/hoteltonight/MBProgressHUD.git', :branch => 'test2' }

s.description = 'MBProgressHUD is an iOS drop-in class that displays a translucent HUD with a ' \
'progress indicator and some optional labels while work is being done in a ' \
'background thread. The HUD is meant as a replacement for the undocumented, ' \
'private UIKit UIProgressHUD with some additional features.'

s.source_files = '*.{h,m}'

s.framework = "CoreGraphics"
end
```

And this is the error I would get:
```
-> Installing MBProgressHUD-ht-test3 (0.4.ht)
-> Cloning git repo
$ /usr/local/bin/git branch -r | grep test2$
[!] Failed: /usr/local/bin/git branch -r | grep test2$
[!] Cache unable to find git reference `test2' for `https://github.com/hoteltonight/MBProgressHUD.git' (256).
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/downloader/git.rb:101:in `ensure_remote_branch_exists'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/downloader/git.rb:135:in `download_branch'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/downloader/git.rb:164:in `download_branch'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/downloader/git.rb:21:in `download'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/installer.rb:83:in `download_pod'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/installer.rb:61:in `install_dependencies!'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/installer.rb:50:in `each'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/installer.rb:50:in `install_dependencies!'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/installer.rb:120:in `install!'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/command/install.rb:46:in `run_install_with_update'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/command/install.rb:52:in `run'
/Users/rayll/dev/github/CocoaPods/lib/cocoapods/command.rb:76:in `run'
/Users/rayll/dev/github/CocoaPods/bin/pod:12
```

I'm just learning ruby, so if there's anything wrong with these changes, I'd appreciate the feedback.

Thanks!