From e031a0ee8a6474154c780e31da2370a66d578cdc Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Mon, 20 Jun 2016 10:22:13 -0400 Subject: [PATCH] Commit without executing hooks, fixes #468 --- git/index/base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/git/index/base.py b/git/index/base.py index 3e68f843c..524b4568d 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -931,19 +931,24 @@ def move(self, items, skip_errors=False, **kwargs): return out def commit(self, message, parent_commits=None, head=True, author=None, - committer=None, author_date=None, commit_date=None): + committer=None, author_date=None, commit_date=None, + skip_hooks=False): """Commit the current default index file, creating a commit object. For more information on the arguments, see tree.commit. :note: If you have manually altered the .entries member of this instance, don't forget to write() your changes to disk beforehand. + Passing skip_hooks=True is the equivalent of using `-n` + or `--no-verify` on the command line. :return: Commit object representing the new commit""" - run_commit_hook('pre-commit', self) + if not skip_hooks: + run_commit_hook('pre-commit', self) tree = self.write_tree() rval = Commit.create_from_tree(self.repo, tree, message, parent_commits, head, author=author, committer=committer, author_date=author_date, commit_date=commit_date) - run_commit_hook('post-commit', self) + if not skip_hooks: + run_commit_hook('post-commit', self) return rval @classmethod