Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: git_cl.py

Issue 5972005: Add support for post-dcommit hooks (Closed) Base URL: http://git.chromium.org/git/git-cl.git@master
Patch Set: move code outside of master Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/post-dcommit-hook-test.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index ea1238261dc8c1aa2fe6d30485a13264bd1de242..d0419bcf7162b9f846d3b1f969b0a68ad503a3cd 100644
--- a/git_cl.py
+++ b/git_cl.py
@@ -29,6 +29,7 @@ except ImportError:
DEFAULT_SERVER = 'http://codereview.appspot.com'
PREDCOMMIT_HOOK = '.git/hooks/pre-cl-dcommit'
+POSTDCOMMIT_HOOK = '.git/hooks/post-cl-dcommit'
PREUPLOAD_HOOK = '.git/hooks/pre-cl-upload'
DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
@@ -971,6 +972,7 @@ def SendUpstream(parser, args, cmd):
# Stuff our change into the merge branch.
# We wrap in a try...finally block so if anything goes wrong,
# we clean up the branches.
+ retcode = -1
try:
RunGit(['checkout', '-q', '-b', MERGE_BRANCH, base_branch])
RunGit(['merge', '--squash', cl.GetBranchRef()])
@@ -986,12 +988,15 @@ def SendUpstream(parser, args, cmd):
logging.debug(output)
else:
# dcommit the merge branch.
- output = RunGit(['svn', 'dcommit', '--no-rebase'])
+ retcode, output = RunGitWithCode(['svn', 'dcommit', '--no-rebase'])
finally:
# And then swap back to the original branch and clean up.
RunGit(['checkout', '-q', cl.GetBranch()])
RunGit(['branch', '-D', MERGE_BRANCH])
+ if retcode == 0 and os.path.isfile(POSTDCOMMIT_HOOK):
Evan Martin 2010/12/23 00:32:07 My point was that you don't need to check retcode
sadrul 2010/12/23 00:41:32 Ah. I wasn't sure if that would always be the case
+ RunHook(POSTDCOMMIT_HOOK, upstream_branch=base_branch, error_ok=True)
+
if cl.GetIssue():
if cmd == 'dcommit' and 'Committed r' in output:
revision = re.match('.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1)
« no previous file with comments | « no previous file | test/post-dcommit-hook-test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698