mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
pre-commit env var exposed
This commit is contained in:
parent
f32bc648f0
commit
9e0b4a9d4d
2 changed files with 12 additions and 0 deletions
|
|
@ -347,6 +347,9 @@ def run(
|
||||||
if args.checkout_type:
|
if args.checkout_type:
|
||||||
environ['PRE_COMMIT_CHECKOUT_TYPE'] = args.checkout_type
|
environ['PRE_COMMIT_CHECKOUT_TYPE'] = args.checkout_type
|
||||||
|
|
||||||
|
# Set pre_commit flag
|
||||||
|
environ['PRE_COMMIT'] = '1'
|
||||||
|
|
||||||
with contextlib.ExitStack() as exit_stack:
|
with contextlib.ExitStack() as exit_stack:
|
||||||
if stash:
|
if stash:
|
||||||
exit_stack.enter_context(staged_files_only(store.directory))
|
exit_stack.enter_context(staged_files_only(store.directory))
|
||||||
|
|
|
||||||
|
|
@ -1028,3 +1028,12 @@ def test_skipped_without_any_setup_for_post_checkout(in_git_dir, store):
|
||||||
environ = {'_PRE_COMMIT_SKIP_POST_CHECKOUT': '1'}
|
environ = {'_PRE_COMMIT_SKIP_POST_CHECKOUT': '1'}
|
||||||
opts = run_opts(hook_stage='post-checkout')
|
opts = run_opts(hook_stage='post-checkout')
|
||||||
assert run(C.CONFIG_FILE, store, opts, environ=environ) == 0
|
assert run(C.CONFIG_FILE, store, opts, environ=environ) == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_pre_commit_env_variable_set(cap_out, store, repo_with_passing_hook):
|
||||||
|
args = run_opts()
|
||||||
|
environ: EnvironT = {}
|
||||||
|
ret, printed = _do_run(
|
||||||
|
cap_out, store, repo_with_passing_hook, args, environ,
|
||||||
|
)
|
||||||
|
assert environ['PRE_COMMIT'] == '1'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue