mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Add error handling for relpath ValueError, fixes #2530
This commit is contained in:
parent
0827de1864
commit
6a11b801ef
1 changed files with 8 additions and 1 deletions
|
|
@ -165,7 +165,14 @@ def _adjust_args_and_chdir(args: argparse.Namespace) -> None:
|
|||
toplevel = git.get_root()
|
||||
os.chdir(toplevel)
|
||||
|
||||
args.config = os.path.relpath(args.config)
|
||||
try:
|
||||
args.config = os.path.relpath(args.config)
|
||||
# https://github.com/pre-commit/pre-commit/issues/2530
|
||||
# os.relpath will fail with a ValueError if the two directories are on
|
||||
# two different drives on Windows and since the path is made relative
|
||||
# for display purposes only we can ignore the error
|
||||
except ValueError:
|
||||
pass
|
||||
if args.command in {'run', 'try-repo'}:
|
||||
args.files = [os.path.relpath(filename) for filename in args.files]
|
||||
if args.commit_msg_filename is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue