lib/git-up.rb in git-up-0.1.0 vs lib/git-up.rb in git-up-0.2.0
- old
+ new
@@ -10,14 +10,16 @@
def run
system "git fetch"
with_stash do
returning_to_current_branch do
+ col_width = @repo.branches.map { |b| b.name.length }.max + 1
+
@repo.branches.each do |branch|
next unless remote = remote_for_branch(branch)
- print branch.name.ljust(20)
+ print branch.name.ljust(col_width)
if remote.commit.sha == branch.commit.sha
puts "up to date".green
next
end
@@ -45,14 +47,11 @@
puts "Here's what Git said:".red
puts e.output
end
def remote_for_branch(branch)
- if remote_name = @repo.config["branch.#{branch.name}.remote"]
- @repo.remotes.find { |r| r.name == "#{remote_name}/#{branch.name}" }
- else
- nil
- end
+ remote_name = @repo.config["branch.#{branch.name}.remote"] || "origin"
+ @repo.remotes.find { |r| r.name == "#{remote_name}/#{branch.name}" }
end
def with_stash
stashed = false