lib/git-up.rb in git-up-0.5.5 vs lib/git-up.rb in git-up-0.5.7
- old
+ new
@@ -3,11 +3,11 @@
class GitUp
def run
command = ['git', 'fetch', '--multiple']
command << '--prune' if prune?
- command += remotes
+ command += config("fetch.all") ? ['--all'] : 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
@@ -27,10 +27,15 @@
end
def rebase_all_branches
col_width = branches.map { |b| b.name.length }.max + 1
+ branches.sort_by! do |b|
+ # perhaps add some way to customize sorting?
+ b.name
+ end
+
branches.each do |branch|
remote = remote_map[branch.name]
print branch.name.ljust(col_width)
@@ -50,10 +55,11 @@
puts "fast-forwarding...".yellow
else
puts "rebasing...".yellow
end
+ log(branch, remote)
checkout(branch.name)
rebase(remote)
end
end
@@ -136,14 +142,21 @@
unless on_branch?(branch_name)
raise GitError.new("Failed to checkout #{branch_name}", output)
end
end
+ def log(branch, remote)
+ if log_hook = config("rebase.log-hook")
+ system('sh', '-c', log_hook, 'git-up', branch.name, remote.name)
+ end
+ end
+
def rebase(target_branch)
current_branch = repo.head
+ arguments = config("rebase.arguments")
- output, err = repo.git.sh("#{Grit::Git.git_binary} rebase #{target_branch.name}")
+ output, err = repo.git.sh("#{Grit::Git.git_binary} rebase #{arguments} #{target_branch.name}")
unless on_branch?(current_branch.name) and is_fast_forward?(current_branch, target_branch)
raise GitError.new("Failed to rebase #{current_branch.name} onto #{target_branch.name}", output+err)
end
end
@@ -241,17 +254,10 @@
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
+ repo.git.status(:porcelain => true, :'untracked-files' => 'no').split("\n").count
end
end
def config(key)
repo.config["git-up.#{key}"]