Skip to content

Commit

Permalink
move patch discarding inside try for staged_files_only
Browse files Browse the repository at this point in the history
there's a rare race outlined in pre-commit#2287
  • Loading branch information
asottile authored and saravankrish committed Jul 7, 2023
1 parent a171f40 commit 138f726
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pre_commit/staged_files_only.py
Expand Up @@ -66,9 +66,9 @@ def _unstaged_changes_cleared(patch_dir: str) -> Generator[None, None, None]:

# prevent recursive post-checkout hooks (#1418)
no_checkout_env = dict(os.environ, _PRE_COMMIT_SKIP_POST_CHECKOUT='1')
cmd_output_b(*_CHECKOUT_CMD, env=no_checkout_env)

try:
cmd_output_b(*_CHECKOUT_CMD, env=no_checkout_env)
yield
finally:
# Try to apply the patch we saved
Expand Down

0 comments on commit 138f726

Please sign in to comment.