Skip to content

Commit without executing hooks, fixes #468 #479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down