Commit 0ba7f967 authored by maruel@chromium.org's avatar maruel@chromium.org

Add support for post-dcommit/post-push hooks.

Patch contributed by sadrul@chromium.org

Review URL: http://codereview.chromium.org/5972005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@71097 0039d316-1c4b-4281-b951-d872f2087c98
parent c76e675f
......@@ -29,6 +29,7 @@ except ImportError:
DEFAULT_SERVER = 'http://codereview.appspot.com'
PREDCOMMIT_HOOK = '.git/hooks/pre-cl-dcommit'
POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
PREUPLOAD_HOOK = '.git/hooks/pre-cl-upload'
DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
......@@ -973,6 +974,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()])
......@@ -988,7 +990,7 @@ 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()])
......@@ -1008,6 +1010,12 @@ def SendUpstream(parser, args, cmd):
'(you may be prompted for your codereview password)...')
cl.CloseIssue()
cl.SetIssue(0)
if retcode == 0:
hook = POSTUPSTREAM_HOOK_PATTERN % cmd
if os.path.isfile(hook):
RunHook(hook, upstream_branch=base_branch, error_ok=True)
return 0
......
#!/bin/bash
set -e
. ./test-lib.sh
setup_initsvn
setup_gitsvn
(
set -e
cd git-svn
cat > .git/hooks/post-cl-dcommit << _EOF
#!/bin/bash
git branch -m COMMITTED
_EOF
chmod +x .git/hooks/post-cl-dcommit
git config rietveld.server localhost:1
git checkout -q --track -b work
echo "some work done" >> test
git add test; git commit -q -m "work"
test_expect_success "dcommitted code" \
"$GIT_CL dcommit -f --tbr --bypass-hooks -m 'dcommit'"
test_expect_success "post-cl-dcommit hook executed" \
"git symbolic-ref HEAD | grep -q COMMITTED"
)
SUCCESS=$?
cleanup
if [ $SUCCESS == 0 ]; then
echo PASS
fi
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