mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #436 from pre-commit/warn_cygwin_mismatched
Warn on cygwin python/git mismatch. Resolves #354
This commit is contained in:
commit
88f9f76e48
2 changed files with 25 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import functools
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
from pre_commit.errors import FatalError
|
from pre_commit.errors import FatalError
|
||||||
from pre_commit.util import CalledProcessError
|
from pre_commit.util import CalledProcessError
|
||||||
|
|
@ -102,3 +103,26 @@ def get_files_matching(all_file_list_strategy):
|
||||||
get_staged_files_matching = get_files_matching(get_staged_files)
|
get_staged_files_matching = get_files_matching(get_staged_files)
|
||||||
get_all_files_matching = get_files_matching(get_all_files)
|
get_all_files_matching = get_files_matching(get_all_files)
|
||||||
get_conflicted_files_matching = get_files_matching(get_conflicted_files)
|
get_conflicted_files_matching = get_files_matching(get_conflicted_files)
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_cygwin_mismatch():
|
||||||
|
"""See https://github.com/pre-commit/pre-commit/issues/354"""
|
||||||
|
if sys.platform in ('cygwin', 'win32'): # pragma: no cover (windows)
|
||||||
|
is_cygwin_python = sys.platform == 'cygwin'
|
||||||
|
toplevel = cmd_output('git', 'rev-parse', '--show-toplevel')[1]
|
||||||
|
is_cygwin_git = toplevel.startswith('/')
|
||||||
|
|
||||||
|
if is_cygwin_python ^ is_cygwin_git:
|
||||||
|
exe_type = {True: '(cygwin)', False: '(windows)'}
|
||||||
|
logger.warn(
|
||||||
|
'pre-commit has detected a mix of cygwin python / git\n'
|
||||||
|
'This combination is not supported, it is likely you will '
|
||||||
|
'receive an error later in the program.\n'
|
||||||
|
'Make sure to use cygwin git+python while using cygwin\n'
|
||||||
|
'These can be installed through the cygwin installer.\n'
|
||||||
|
' - python {}\n'
|
||||||
|
' - git {}\n'.format(
|
||||||
|
exe_type[is_cygwin_python],
|
||||||
|
exe_type[is_cygwin_git],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ def main(argv=None):
|
||||||
|
|
||||||
with error_handler():
|
with error_handler():
|
||||||
add_logging_handler(args.color)
|
add_logging_handler(args.color)
|
||||||
|
git.check_for_cygwin_mismatch()
|
||||||
runner = Runner.create()
|
runner = Runner.create()
|
||||||
|
|
||||||
if args.command == 'install':
|
if args.command == 'install':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue