diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2019-03-15 15:34:45 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2019-03-15 15:35:38 +0100 |
commit | efa34acc59ffcd88328048174592ba54a80b0acd (patch) | |
tree | b77933efe01f81b1b312fe6a7c4ad640decf4f35 | |
parent | 94e0aec3f6ca6a3754aad981507406bcc7e112c3 (diff) |
gits: also rebase onto origin/master
Change-Id: Icb331d225e8ec1b75d199e40c61c741a44c9a87c
-rwxr-xr-x | src/gits | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -320,6 +320,30 @@ def rebase(git_dir): ask_reset_hard_or_push_f(git_dir, orig_branch, upstream_branch) + if git_has_modifications(git_dir): + raise SkipThisRepo() + + # Rebase onto origin/master? Only when this isn't already the master branch + if upstream_branch != 'origin/master': + ahead, behind = git_ahead_behind(git_dir, orig_branch, 'origin/master') + + if ahead and behind: + do_rebase = ask(git_dir, '%r diverged from master. git rebase -i origin/master?' % orig_branch, + "<empty> don't rebase", + 'ok rebase onto origin/master', + valid_answers=('', 'ok')) + + if do_rebase == 'ok': + git(git_dir, 'rebase', '-i', 'origin/master') + # On conflicts, we'll exit with error implicitly + + do_push = ask(git_dir, 'git push -f to overwrite %r?' % upstream_branch, + "<empty> don't overwrite upstream", + 'P `push -f` to overwrite upstream (P in caps!)', + valid_answers=('', 'P')) + if do_push == 'P': + git(git_dir, 'push', '-f') + return orig_branch |