aboutsummaryrefslogtreecommitdiff
path: root/git/index/fun.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2017-11-19 15:57:17 +0100
committerGitHub <noreply@github.com>2017-11-19 15:57:17 +0100
commitd91ae75401b851b71fcc6f4dcf7eb29ed2a63369 (patch)
treea56d103e434f06ded3fde16f8dfa3706a6beebec /git/index/fun.py
parent610d4c97485d2c0d4f65b87f2620a84e0df99341 (diff)
parenteae04bf7b0620a0ef950dd39af7f07f3c88fd15f (diff)
downloadGitPython-d91ae75401b851b71fcc6f4dcf7eb29ed2a63369.tar.gz
GitPython-d91ae75401b851b71fcc6f4dcf7eb29ed2a63369.zip
Merge pull request #693 from satahippy/master
commit-msg hook support
Diffstat (limited to 'git/index/fun.py')
-rw-r--r--git/index/fun.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/git/index/fun.py b/git/index/fun.py
index 7f7518e1..c01a32b8 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -62,10 +62,11 @@ def hook_path(name, git_dir):
return osp.join(git_dir, 'hooks', name)
-def run_commit_hook(name, index):
+def run_commit_hook(name, index, *args):
"""Run the commit hook of the given name. Silently ignores hooks that do not exist.
:param name: name of hook, like 'pre-commit'
:param index: IndexFile instance
+ :param args: arguments passed to hook file
:raises HookExecutionError: """
hp = hook_path(name, index.repo.git_dir)
if not os.access(hp, os.X_OK):
@@ -75,7 +76,7 @@ def run_commit_hook(name, index):
env['GIT_INDEX_FILE'] = safe_decode(index.path) if PY3 else safe_encode(index.path)
env['GIT_EDITOR'] = ':'
try:
- cmd = subprocess.Popen(hp,
+ cmd = subprocess.Popen([hp] + list(args),
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@@ -93,7 +94,7 @@ def run_commit_hook(name, index):
if cmd.returncode != 0:
stdout = force_text(stdout, defenc)
stderr = force_text(stderr, defenc)
- raise HookExecutionError(hp, cmd.returncode, stdout, stderr)
+ raise HookExecutionError(hp, cmd.returncode, stderr, stdout)
# end handle return code