mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 00:24:47 +04:00
add check on pre-push stage: exit if staged files not committed yet
This commit is contained in:
parent
924680e974
commit
80e6149cf2
3 changed files with 42 additions and 1 deletions
|
|
@ -371,7 +371,14 @@ def run(
|
|||
environ.get('_PRE_COMMIT_SKIP_POST_CHECKOUT')
|
||||
):
|
||||
return 0
|
||||
|
||||
# prevent pushing staged files not committed (#2486)
|
||||
if (
|
||||
args.hook_stage == 'pre-push' and git.get_staged_files()
|
||||
):
|
||||
logger.error(
|
||||
'Staged files found. Please commit before pushing',
|
||||
)
|
||||
return 1
|
||||
# Expose prepare_commit_message_source / commit_object_name
|
||||
# as environment variables for the hooks
|
||||
if args.prepare_commit_message_source:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue