Merge "Vendor a copy of Gerrit's commit-msg Git hook"
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from . import hooks
|
||||
|
||||
import argparse
|
||||
import configparser
|
||||
import datetime
|
||||
@@ -395,7 +397,10 @@ def set_hooks_commit_msg(remote, target_file):
|
||||
|
||||
if not os.path.exists(target_file) or UPDATE:
|
||||
remote_url = get_remote_url(remote)
|
||||
if (remote_url.startswith('http://') or
|
||||
if not remote_url:
|
||||
with open(target_file, 'w') as f:
|
||||
f.write(hooks.COMMIT_MSG)
|
||||
elif (remote_url.startswith('http://') or
|
||||
remote_url.startswith('https://')):
|
||||
hook_url = urljoin(remote_url, '/tools/hooks/commit-msg')
|
||||
if VERBOSE:
|
||||
@@ -585,6 +590,11 @@ def get_remote_url(remote):
|
||||
URL rather than the fetch URL.
|
||||
"""
|
||||
|
||||
# Short-circuit to a false value if the remote passed in is falsey, used
|
||||
# for determining commit-msg hook retrieval behavior
|
||||
if not remote:
|
||||
return remote
|
||||
|
||||
push_url = git_config_get_value('remote.%s' % remote, 'pushurl')
|
||||
if push_url is not None:
|
||||
# Git rewrites pushurl using insteadOf but not pushInsteadOf.
|
||||
@@ -1574,6 +1584,9 @@ additional information:
|
||||
help="Regenerate Change-id before submitting")
|
||||
parser.add_argument("-r", "--remote", dest="remote",
|
||||
help="git remote to use for gerrit")
|
||||
parser.add_argument("--remote-hook", dest="remote_hook",
|
||||
action="store_true",
|
||||
help="Fetch the remote version of the commit-msg hook")
|
||||
parser.add_argument("--use-pushurl", dest="usepushurl",
|
||||
action="store_true",
|
||||
help="Use remote push-url logic instead of separate"
|
||||
@@ -1808,7 +1821,10 @@ additional information:
|
||||
have_hook = os.path.exists(hook_file) and os.access(hook_file, os.X_OK)
|
||||
|
||||
if not have_hook:
|
||||
set_hooks_commit_msg(remote, hook_file)
|
||||
if options.remote_hook:
|
||||
set_hooks_commit_msg(remote, hook_file)
|
||||
else:
|
||||
set_hooks_commit_msg(None, hook_file)
|
||||
|
||||
if options.setup:
|
||||
if options.finish and not options.dry:
|
||||
|
||||
Reference in New Issue
Block a user