mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
Add PRE_COMMIT_ALL_FILES environment variable
Add a `PRE_COMMIT_ALL_FILES` environment variable to allow hooks to determine if pre-commit was called with `--all-files`. This can be useful if different behavior is desired when running pre-commit over all files vs only staged files.
This commit is contained in:
parent
7858ad066f
commit
e03b5eb218
2 changed files with 12 additions and 0 deletions
|
|
@ -524,6 +524,15 @@ def test_checkout_type(cap_out, store, repo_with_passing_hook):
|
|||
assert environ['PRE_COMMIT_CHECKOUT_TYPE'] == '1'
|
||||
|
||||
|
||||
def test_all_files(cap_out, store, repo_with_passing_hook):
|
||||
args = run_opts(all_files=True)
|
||||
environ: MutableMapping[str, str] = {}
|
||||
ret, printed = _do_run(
|
||||
cap_out, store, repo_with_passing_hook, args, environ,
|
||||
)
|
||||
assert environ['PRE_COMMIT_ALL_FILES'] == '1'
|
||||
|
||||
|
||||
def test_has_unmerged_paths(in_merge_conflict):
|
||||
assert _has_unmerged_paths() is True
|
||||
cmd_output('git', 'add', '.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue