Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow pre-commit run --files ... against unmerged files #2484

Merged
merged 1 commit into from Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pre_commit/commands/run.py
Expand Up @@ -333,7 +333,7 @@ def run(
stash = not args.all_files and not args.files

# Check if we have unresolved merge conflict files and fail fast.
if _has_unmerged_paths():
if stash and _has_unmerged_paths():
logger.error('Unmerged files. Resolve before committing.')
return 1
if bool(args.from_ref) != bool(args.to_ref):
Expand Down
7 changes: 7 additions & 0 deletions tests/commands/run_test.py
Expand Up @@ -536,6 +536,13 @@ def test_merge_conflict(cap_out, store, in_merge_conflict):
assert b'Unmerged files. Resolve before committing.' in printed


def test_files_during_merge_conflict(cap_out, store, in_merge_conflict):
opts = run_opts(files=['placeholder'])
ret, printed = _do_run(cap_out, store, in_merge_conflict, opts)
assert ret == 0
assert b'Bash hook' in printed


def test_merge_conflict_modified(cap_out, store, in_merge_conflict):
# Touch another file so we have unstaged non-conflicting things
assert os.path.exists('placeholder')
Expand Down