mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
fix hooks firing during staged_files_only
This commit is contained in:
parent
0670e0b287
commit
928938a6a1
5 changed files with 53 additions and 5 deletions
|
|
@ -103,10 +103,12 @@ def cwd(path):
|
|||
os.chdir(original_cwd)
|
||||
|
||||
|
||||
def git_commit(*args, fn=cmd_output, msg='commit!', **kwargs):
|
||||
def git_commit(*args, fn=cmd_output, msg='commit!', all_files=True, **kwargs):
|
||||
kwargs.setdefault('stderr', subprocess.STDOUT)
|
||||
|
||||
cmd = ('git', 'commit', '--allow-empty', '--no-gpg-sign', '-a') + args
|
||||
cmd = ('git', 'commit', '--allow-empty', '--no-gpg-sign', *args)
|
||||
if all_files: # allow skipping `-a` with `all_files=False`
|
||||
cmd += ('-a',)
|
||||
if msg is not None: # allow skipping `-m` with `msg=None`
|
||||
cmd += ('-m', msg)
|
||||
ret, out, _ = fn(*cmd, **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue