mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-05 15:59:16 -06:00
Simplify has_unmerged_paths
This commit is contained in:
@@ -30,9 +30,6 @@ COLS = int(subprocess.Popen(['tput', 'cols'], stdout=subprocess.PIPE).communicat
|
||||
|
||||
PASS_FAIL_LENGTH = 6
|
||||
|
||||
# Grabbed from `git help status`
|
||||
CONFLICTING_GIT_STATUSES = set(('DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU'))
|
||||
|
||||
|
||||
def install(runner):
|
||||
"""Install the pre-commit hooks."""
|
||||
@@ -233,11 +230,8 @@ def _run_hook(runner, hook_id, args, write):
|
||||
|
||||
|
||||
def _has_unmerged_paths(runner):
|
||||
_, stdout, _ = runner.cmd_runner.run(
|
||||
['git', 'status', '--short'], retcode=None,
|
||||
)
|
||||
codes = set(line[:2] for line in stdout.splitlines())
|
||||
return codes & CONFLICTING_GIT_STATUSES > set()
|
||||
_, stdout, _ = runner.cmd_runner.run(['git', 'ls-files', '--unmerged'])
|
||||
return bool(stdout.strip())
|
||||
|
||||
|
||||
def run(runner, args, write=sys.stdout.write):
|
||||
|
||||
Reference in New Issue
Block a user