Commit fe83cfa6 authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

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/1483030Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
parent fe34723a
...@@ -223,6 +223,8 @@ def main(args=None): ...@@ -223,6 +223,8 @@ def main(args=None):
parser.add_argument('--no_fetch', '--no-fetch', '-n', parser.add_argument('--no_fetch', '--no-fetch', '-n',
action='store_true', action='store_true',
help='Skip fetching remotes.') help='Skip fetching remotes.')
parser.add_argument(
'--current', action='store_true', help='Only rebase the current branch.')
parser.add_argument('branches', nargs='*', parser.add_argument('branches', nargs='*',
help='Branches to be rebased. All branches are assumed ' help='Branches to be rebased. All branches are assumed '
'if none specified.') 'if none specified.')
...@@ -257,9 +259,13 @@ def main(args=None): ...@@ -257,9 +259,13 @@ def main(args=None):
else: else:
git.freeze() # just in case there are any local changes. 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() skipped, branch_tree = git.get_branch_tree()
if opts.branches: if branches_to_rebase:
skipped = set(skipped).intersection(set(opts.branches)) skipped = set(skipped).intersection(branches_to_rebase)
for branch in skipped: for branch in skipped:
print 'Skipping %s: No upstream specified' % branch print 'Skipping %s: No upstream specified' % branch
...@@ -279,7 +285,7 @@ def main(args=None): ...@@ -279,7 +285,7 @@ def main(args=None):
# towards the leaves. # towards the leaves.
for branch, parent in git.topo_iter(branch_tree): for branch, parent in git.topo_iter(branch_tree):
# Only rebase specified branches, unless none specified. # 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 continue
if git.is_dormant(branch): if git.is_dormant(branch):
print 'Skipping dormant branch', branch print 'Skipping dormant branch', branch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment