From e84c6f9e9128b00589274850f5ad76f86b020af4 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 21 Dec 2011 14:34:40 +0000 Subject: [PATCH] Add --finish option to git-review. Closes bug 902858. Folks using git flow are used to using a command, "git flow finish" which merges their changes back in to develop and then deletes the branch. We obviously do not want our git flow users to do that, since we don't want the merge commits. So this adds a -f/--finish option which allows you to get rid of the topic branch after successful submission. Change-Id: I0f3b2a5b4826de074480b684ec9b5603788f15b7 --- git-review | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/git-review b/git-review index b300edb..103e322 100755 --- a/git-review +++ b/git-review @@ -496,6 +496,27 @@ def download_review(review): print output return status + print "Switched to branch '%s'" % branch_name + return 0 + + +def finish_branch(target_branch): + local_branch = get_branch_name(target_branch) + if VERBOSE: + print "Switching back to %s and deleting %s" % (target_branch, + local_branch) + checkout_cmd = "git checkout %s" % target_branch + (status, output) = run_command_status(checkout_cmd) + if status != 0: + print output + return status + print "Switched to branch '%s'" % target_branch + close_cmd = "git branch -D %s" % local_branch + (status, output) = run_command_status(close_cmd) + if status != 0: + print output + return status + print "Deleted branch '%s'" % local_branch return 0 @@ -538,6 +559,9 @@ def main(): parser.add_option("-s", "--setup", dest="setup", action="store_true", help="Just run the repo setup commands but don't " "submit anything") + parser.add_option("-f", "--finish", dest="finish", action="store_true", + help="Close down this branch and switch back to " + "master on successful submission") parser.add_option("-y", "--yes", dest="yes", action="store_true", help="Indicate that you do, in fact, understand if you " "are submitting more than one patch") @@ -593,6 +617,9 @@ def main(): (status, output) = run_command_status(cmd) print output + if options.finish and not options.dry and status == 0: + status = finish_branch(branch) + print_exit_message(status, needs_update)