mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
Adjust git dir when checking for merge in worktree
This commit is contained in:
parent
e35ba8d463
commit
07af54024c
2 changed files with 20 additions and 5 deletions
|
|
@ -3,6 +3,8 @@ import os.path
|
|||
from typing import Optional
|
||||
from typing import Sequence
|
||||
|
||||
from pre_commit_hooks.util import cmd_output
|
||||
|
||||
|
||||
CONFLICT_PATTERNS = [
|
||||
b'<<<<<<< ',
|
||||
|
|
@ -12,13 +14,14 @@ CONFLICT_PATTERNS = [
|
|||
]
|
||||
|
||||
|
||||
def is_in_merge() -> int:
|
||||
def is_in_merge() -> bool:
|
||||
git_dir = cmd_output('git', 'rev-parse', '--git-dir').rstrip()
|
||||
return (
|
||||
os.path.exists(os.path.join('.git', 'MERGE_MSG')) and
|
||||
os.path.exists(os.path.join(git_dir, 'MERGE_MSG')) and
|
||||
(
|
||||
os.path.exists(os.path.join('.git', 'MERGE_HEAD')) or
|
||||
os.path.exists(os.path.join('.git', 'rebase-apply')) or
|
||||
os.path.exists(os.path.join('.git', 'rebase-merge'))
|
||||
os.path.exists(os.path.join(git_dir, 'MERGE_HEAD')) or
|
||||
os.path.exists(os.path.join(git_dir, 'rebase-apply')) or
|
||||
os.path.exists(os.path.join(git_dir, 'rebase-merge'))
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue