Skip to content

Commit 4896fa2

Browse files
authored
Merge pull request #479 from peterbe/commit-without-executing-hooks
Commit without executing hooks, fixes #468
2 parents 3c6e5ad + e031a0e commit 4896fa2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

git/index/base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,19 +931,24 @@ def move(self, items, skip_errors=False, **kwargs):
931931
return out
932932

933933
def commit(self, message, parent_commits=None, head=True, author=None,
934-
committer=None, author_date=None, commit_date=None):
934+
committer=None, author_date=None, commit_date=None,
935+
skip_hooks=False):
935936
"""Commit the current default index file, creating a commit object.
936937
For more information on the arguments, see tree.commit.
937938
938939
:note: If you have manually altered the .entries member of this instance,
939940
don't forget to write() your changes to disk beforehand.
941+
Passing skip_hooks=True is the equivalent of using `-n`
942+
or `--no-verify` on the command line.
940943
:return: Commit object representing the new commit"""
941-
run_commit_hook('pre-commit', self)
944+
if not skip_hooks:
945+
run_commit_hook('pre-commit', self)
942946
tree = self.write_tree()
943947
rval = Commit.create_from_tree(self.repo, tree, message, parent_commits,
944948
head, author=author, committer=committer,
945949
author_date=author_date, commit_date=commit_date)
946-
run_commit_hook('post-commit', self)
950+
if not skip_hooks:
951+
run_commit_hook('post-commit', self)
947952
return rval
948953

949954
@classmethod

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy