mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
Merge pull request #2484 from pre-commit/allow-files-when-unmerged
allow `pre-commit run --files ...` against unmerged files
This commit is contained in:
commit
51e6d655b8
2 changed files with 8 additions and 1 deletions
|
|
@ -333,7 +333,7 @@ def run(
|
||||||
stash = not args.all_files and not args.files
|
stash = not args.all_files and not args.files
|
||||||
|
|
||||||
# Check if we have unresolved merge conflict files and fail fast.
|
# 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.')
|
logger.error('Unmerged files. Resolve before committing.')
|
||||||
return 1
|
return 1
|
||||||
if bool(args.from_ref) != bool(args.to_ref):
|
if bool(args.from_ref) != bool(args.to_ref):
|
||||||
|
|
|
||||||
|
|
@ -536,6 +536,13 @@ def test_merge_conflict(cap_out, store, in_merge_conflict):
|
||||||
assert b'Unmerged files. Resolve before committing.' in printed
|
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):
|
def test_merge_conflict_modified(cap_out, store, in_merge_conflict):
|
||||||
# Touch another file so we have unstaged non-conflicting things
|
# Touch another file so we have unstaged non-conflicting things
|
||||||
assert os.path.exists('placeholder')
|
assert os.path.exists('placeholder')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue