From d06c95de553738bb8ec111eef769186ec1e5d05b Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Wed, 8 Aug 2012 22:03:02 +0200 Subject: [PATCH] Due to gerrit bug regeneration of Change-Id must be nessecary Simultaneously dirrect push to master and uploading a gerrit patch for review to some branches is currently not supported. To circumvent it a new option --new-changeid is provided. git-review --dry-run also supported now: only the command is written without actually execute it. Special thank goes to Roan Kattouw for helping out with GIT_EDITOR command. Bug #1032675 Change-Id: Id1433c11ce9f0a2ad51b3bdfa581fdb86cff8f0e --- git-review | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/git-review b/git-review index 8628ee03..88143786 100755 --- a/git-review +++ b/git-review @@ -655,6 +655,9 @@ def main(): "-D/--draft is used.") parser.add_argument("-n", "--dry-run", dest="dry", action="store_true", help="Don't actually submit the branch for review") + parser.add_argument("-i", "--new-changeid", dest="regenerate", + action="store_true", + help="Regenerate Change-id before submitting") parser.add_argument("-r", "--remote", dest="remote", help="git remote to use for gerrit") parser.add_argument("-R", "--no-rebase", dest="rebase", @@ -753,6 +756,17 @@ def main(): cmd = "git push %s HEAD:refs/%s/%s/%s" % (remote, ref, branch, topic) + if options.regenerate: + print("Amending the commit to regenerate the change id\n") + regenerate_cmd = "git commit --amend" + if options.dry: + print("\tGIT_EDITOR=\"sed -i -e '/^Change-Id:/d'\" %s\n" % + regenerate_cmd) + else: + run_command(regenerate_cmd, + env=dict(GIT_EDITOR="sed -i -e " + "'/^Change-Id:/d'")) + if options.dry: print("Please use the following command " "to send your commits to review:\n")