diff options
author | Peter Bengtsson <mail@peterbe.com> | 2016-06-20 10:22:13 -0400 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2016-06-20 10:22:33 -0400 |
commit | e031a0ee8a6474154c780e31da2370a66d578cdc (patch) | |
tree | bbfe6bd010d6f6de091b014f663d9e1008599da0 | |
parent | de894298780fd90c199ef9e3959a957a24084b14 (diff) | |
download | gitpython-e031a0ee8a6474154c780e31da2370a66d578cdc.tar.gz |
Commit without executing hooks, fixes #468
-rw-r--r-- | git/index/base.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/git/index/base.py b/git/index/base.py index 3e68f843..524b4568 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -931,19 +931,24 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): 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 |