Add --current to rebase the current branch
Add a shortcut to extend the branches to be rebased with the current
branch without having to type its name.
Change-Id: If2fa117a6418590cdec5e65430f65dcdc825b611
Reviewed-on: https://chromium-review.googlesource.com/c/1483030
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
diff --git a/git_rebase_update.py b/git_rebase_update.py
index 4af4bbd..acf85d3 100755
--- a/git_rebase_update.py
+++ b/git_rebase_update.py
@@ -223,6 +223,8 @@
parser.add_argument('--no_fetch', '--no-fetch', '-n',
action='store_true',
help='Skip fetching remotes.')
+ parser.add_argument(
+ '--current', action='store_true', help='Only rebase the current branch.')
parser.add_argument('branches', nargs='*',
help='Branches to be rebased. All branches are assumed '
'if none specified.')
@@ -257,9 +259,13 @@
else:
git.freeze() # just in case there are any local changes.
+ branches_to_rebase = set(opts.branches)
+ if opts.current:
+ branches_to_rebase.add(git.current_branch())
+
skipped, branch_tree = git.get_branch_tree()
- if opts.branches:
- skipped = set(skipped).intersection(set(opts.branches))
+ if branches_to_rebase:
+ skipped = set(skipped).intersection(branches_to_rebase)
for branch in skipped:
print 'Skipping %s: No upstream specified' % branch
@@ -279,7 +285,7 @@
# towards the leaves.
for branch, parent in git.topo_iter(branch_tree):
# Only rebase specified branches, unless none specified.
- if opts.branches and branch not in opts.branches:
+ if branches_to_rebase and branch not in branches_to_rebase:
continue
if git.is_dormant(branch):
print 'Skipping dormant branch', branch