Skip to content

Commit

Permalink
Don't prune if git doesn't support it
Browse files Browse the repository at this point in the history
  • Loading branch information
aanand committed Apr 19, 2012
1 parent f0b0599 commit da450e7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/git-up.rb
Expand Up @@ -7,6 +7,7 @@ def run
command << '--prune' if prune?
command += remotes

# puts command.join(" ") # TODO: implement a 'debug' config option
system(*command)
raise GitError, "`git fetch` failed" unless $? == 0
@remote_map = nil # flush cache after fetch
Expand Down Expand Up @@ -223,21 +224,26 @@ def use_bundler_config?
end

def prune?
required_version = "1.6.6"
config_value = config("fetch.prune")

case config_value
when 'false'
if git_version < required_version
if config_value == 'true'
puts "Warning: fetch.prune is set to 'true' but your git version doesn't seem to support it (#{git_version} < #{required_version}). Defaulting to 'false'.".yellow
end

false
when nil, 'true'
true
else
puts "Warning: nonsensical value #{config_value.inspect} for fetch.prune. Defaulting to \"true\".".yellow
true
config_value != 'false'
end
end

def config(key)
repo.config["git-up.#{key}"]
end

def git_version
`git --version`[/\d+(\.\d+)+/]
end
end

0 comments on commit da450e7

Please sign in to comment.