Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated rebase functionality to use "git pull --rebase" #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ Default: **true**. Append the `--prune` flag when running `git fetch`, if your g

Default: **false**. Normally, git-up will only fetch remotes for which there is at least one local tracking branch. Setting this option to **true** will make git-up always fetch from all remotes, which is useful if e.g. you use a remote to push to your CI system but never check those branches out.

### git-up.rebase.arguments [string]

Default: **unset**. Additional arguments to pass to `git rebase`. For example, setting this to `--preserve-merges` will recreate your merge commits in the rebased branch.

### git-up.rebase.auto [true|false]

Default: **true**. If this option is set to **false**, git-up will not rebase branches for you. Instead, it will print a message saying they are diverged and let you handle rebasing them later. This can be useful if you have a lot of in-progress work that you don't want to deal with at once, but still want to update other branches.
Expand Down
12 changes: 6 additions & 6 deletions lib/git-up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ def rebase_all_branches
col_width = branches.map { |b| b.name.length }.max + 1

branches.each do |branch|
remote = remote_map[branch.name]
remote = remote_map[branch.name]
curbranch = branch.name.ljust(col_width)
remote_name = repo.config["branch.#{curbranch}.remote"] || "origin"

curbranch = branch.name.ljust(col_width)
if branch.name == repo.head.name
print curbranch.bold
else
Expand Down Expand Up @@ -127,7 +128,7 @@ def rebase_all_branches

log(branch, remote)
checkout(branch.name)
rebase(remote)
rebase(remote, remote_name, curbranch)
end
end

Expand Down Expand Up @@ -218,11 +219,10 @@ def log(branch, remote)
end
end

def rebase(target_branch)
def rebase(target_branch, remote_name, branch_name)
current_branch = repo.head
arguments = config("rebase.arguments")

output, err = repo.git.sh("#{Grit::Git.git_binary} rebase #{arguments} #{target_branch.name}")
output, err = repo.git.sh("#{Grit::Git.git_binary} pull --rebase #{remote_name} #{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)
Expand Down
2 changes: 1 addition & 1 deletion lib/git-up/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class GitUp
VERSION = "0.5.12"
VERSION = "0.5.12.1"
end