mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 10:31:46 +04:00
Add more checks for mingw platform
When the mingw platform is detected, several different path routines will be applied.
This commit is contained in:
parent
9850eae10a
commit
26c6af21ef
4 changed files with 47 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ import distutils.spawn
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import sysconfig
|
||||
|
||||
# work around https://github.com/Homebrew/homebrew-core/issues/30445
|
||||
os.environ.pop('__PYVENV_LAUNCHER__', None)
|
||||
|
|
@ -76,7 +77,10 @@ def _run_legacy():
|
|||
|
||||
def _validate_config():
|
||||
cmd = ('git', 'rev-parse', '--show-toplevel')
|
||||
top_level = subprocess.check_output(cmd).decode('UTF-8').strip()
|
||||
top_level = fix_mingw_path(
|
||||
subprocess.check_output(cmd).decode('UTF-8').
|
||||
strip(),
|
||||
)
|
||||
cfg = os.path.join(top_level, CONFIG)
|
||||
if os.path.isfile(cfg):
|
||||
pass
|
||||
|
|
@ -177,6 +181,21 @@ else:
|
|||
_subprocess_call = subprocess.call
|
||||
|
||||
|
||||
def is_mingw():
|
||||
"""Check whether platform is mingw or not."""
|
||||
return sysconfig.get_platform() in 'mingw'
|
||||
|
||||
|
||||
def fix_mingw_path(path):
|
||||
"""Convert cygwin path to mingw-style path"""
|
||||
if is_mingw():
|
||||
path = subprocess.check_output([
|
||||
'cygpath', '-m',
|
||||
path,
|
||||
]).decode().strip()
|
||||
return path
|
||||
|
||||
|
||||
def main():
|
||||
retv, stdin = _run_legacy()
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue