mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
Using pathlib to handle Windows network mounts
This commit is contained in:
parent
a336a6b0b5
commit
0868006a3c
1 changed files with 11 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ import argparse
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
@ -171,11 +172,17 @@ def _adjust_args_and_chdir(args: argparse.Namespace) -> None:
|
||||||
else:
|
else:
|
||||||
os.chdir(toplevel)
|
os.chdir(toplevel)
|
||||||
|
|
||||||
args.config = os.path.relpath(args.config)
|
args.config = os.path.relpath(unc_path(args.config))
|
||||||
if args.command in {'run', 'try-repo'}:
|
if args.command in {'run', 'try-repo'}:
|
||||||
args.files = [os.path.relpath(filename) for filename in args.files]
|
args.files = [
|
||||||
if args.command == 'try-repo' and os.path.exists(args.repo):
|
os.path.relpath(unc_path(filename)) for filename in args.files
|
||||||
args.repo = os.path.relpath(args.repo)
|
]
|
||||||
|
if args.command == 'try-repo' and os.path.exists(unc_path(args.repo)):
|
||||||
|
args.repo = os.path.relpath(unc_path(args.repo))
|
||||||
|
|
||||||
|
|
||||||
|
def unc_path(file_path: str) -> str:
|
||||||
|
return str(Path(file_path).resolve())
|
||||||
|
|
||||||
|
|
||||||
def main(argv: Optional[Sequence[str]] = None) -> int:
|
def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue