lib/git-up.rb in git-up-0.5.4 vs lib/git-up.rb in git-up-0.5.5
- old
+ new
@@ -98,13 +98,10 @@
end
def with_stash
stashed = false
- status = repo.status
- change_count = status.added.length + status.changed.length + status.deleted.length
-
if change_count > 0
puts "stashing #{change_count} changes".magenta
repo.git.stash
stashed = true
end
@@ -239,9 +236,22 @@
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
+ end
+ end
+
+ def change_count
+ @change_count ||= begin
+ diff_status = repo.status
+ actual_status = repo.git.status(:porcelain => true).split("\n").map {|l| l[3..-1]}
+
+ added = diff_status.added.select { |(x,y)| actual_status.include? x }
+ changed = diff_status.changed.select { |(x,y)| actual_status.include? x }
+ deleted = diff_status.deleted.select { |(x,y)| actual_status.include? x }
+
+ added.length + changed.length + deleted.length
end
end
def config(key)
repo.config["git-up.#{key}"]