summaryrefslogtreecommitdiff
path: root/git/exc.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-12 14:55:31 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-12 14:55:31 +0100
commite8eae18dcc360e6ab96c2291982bd4306adc01b9 (patch)
tree804cc52c1a9976a7274000d9a446bae2b4f032b3 /git/exc.py
parente7671110bc865786ffe61cf9b92bf43c03759229 (diff)
downloadgitpython-e8eae18dcc360e6ab96c2291982bd4306adc01b9.tar.gz
IndexFile.commit() now runs pre-commit and post-commit hooks.
However, it does so only on posix. The test-case will run on posix only as well. Please note that in theory, even on windows we will attempt to run hooks, even though I am not sure that this will actually work. Fixes #81
Diffstat (limited to 'git/exc.py')
-rw-r--r--git/exc.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/git/exc.py b/git/exc.py
index 42191c62..d9b7cbd2 100644
--- a/git/exc.py
+++ b/git/exc.py
@@ -11,17 +11,14 @@ from git.compat import defenc
class InvalidGitRepositoryError(Exception):
-
""" Thrown if the given repository appears to have an invalid format. """
class NoSuchPathError(OSError):
-
""" Thrown if a path could not be access by the system. """
class GitCommandError(Exception):
-
""" Thrown if execution of the git command fails with non-zero status code. """
def __init__(self, command, status, stderr=None, stdout=None):
@@ -41,7 +38,6 @@ class GitCommandError(Exception):
class CheckoutError(Exception):
-
"""Thrown if a file could not be checked out from the index as it contained
changes.
@@ -71,6 +67,20 @@ class CacheError(Exception):
class UnmergedEntriesError(CacheError):
-
"""Thrown if an operation cannot proceed as there are still unmerged
entries in the cache"""
+
+
+class HookExecutionError(Exception):
+ """Thrown if a hook exits with a non-zero exit code. It provides access to the exit code and the string returned
+ via standard output"""
+
+ def __init__(self, command, status, stdout, stderr):
+ self.command = command
+ self.status = status
+ self.stdout = stdout
+ self.stderr = stderr
+
+ def __str__(self):
+ return ("'%s' hook returned with exit code %i\nstdout: '%s'\nstderr: '%s'"
+ % (self.command, self.status, self.stdout, self.stderr))