Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Update to not need special code for :branch (thanks JK)
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats authored and indirect committed Apr 2, 2010
1 parent ffef5a1 commit 57da026
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/bundler/source.rb
Expand Up @@ -268,7 +268,6 @@ class Git < Path
def initialize(options)
super
@uri = options["uri"]
@branch = options["branch"] || "master"
@ref = options["ref"] || options["branch"] || options["tag"] || 'master'
end

Expand Down Expand Up @@ -345,7 +344,7 @@ def cache_path
def cache
if cached?
Bundler.ui.info "Updating #{uri}"
in_cache { git %|fetch --quiet "#{uri}" #{@branch}:#{@branch}| }
in_cache { git %|fetch --quiet "#{uri}" refs/heads/*:refs/heads/*| }
else
Bundler.ui.info "Fetching #{uri}"
FileUtils.mkdir_p(cache_path.dirname)
Expand Down
17 changes: 14 additions & 3 deletions spec/support/builders.rb
Expand Up @@ -371,16 +371,27 @@ def _build(options)
end

class GitUpdater < LibBuilder
WINDOWS = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
NULL = WINDOWS ? "NUL" : "/dev/null"

def silently(str)
`#{str} 2>#{NULL}`
end

def _build(options)
libpath = options[:path] || _default_path

Dir.chdir(libpath) do
`git checkout master`
silently "git checkout master"

if branch = options[:branch]
raise "You can't specify `master` as the branch" if branch == "master"
`git branch #{branch}` unless `git branch | grep #{branch}`.any?
`git checkout #{branch}`

unless `git branch | grep #{branch}`.any?
silently("git branch #{branch}")
end

silently("git checkout #{branch}")
end

current_ref = `git rev-parse HEAD`.strip
Expand Down

0 comments on commit 57da026

Please sign in to comment.