Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51e6d65

Browse files
authored
Merge pull request #2484 from pre-commit/allow-files-when-unmerged
allow `pre-commit run --files ...` against unmerged files
2 parents 6740a17 + 2405caa commit 51e6d65

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

pre_commit/commands/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def run(
333333
stash = not args.all_files and not args.files
334334

335335
# Check if we have unresolved merge conflict files and fail fast.
336-
if _has_unmerged_paths():
336+
if stash and _has_unmerged_paths():
337337
logger.error('Unmerged files. Resolve before committing.')
338338
return 1
339339
if bool(args.from_ref) != bool(args.to_ref):

tests/commands/run_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,13 @@ def test_merge_conflict(cap_out, store, in_merge_conflict):
536536
assert b'Unmerged files. Resolve before committing.' in printed
537537

538538

539+
def test_files_during_merge_conflict(cap_out, store, in_merge_conflict):
540+
opts = run_opts(files=['placeholder'])
541+
ret, printed = _do_run(cap_out, store, in_merge_conflict, opts)
542+
assert ret == 0
543+
assert b'Bash hook' in printed
544+
545+
539546
def test_merge_conflict_modified(cap_out, store, in_merge_conflict):
540547
# Touch another file so we have unstaged non-conflicting things
541548
assert os.path.exists('placeholder')

0 commit comments

Comments
 (0)