Skip to content

Handle config paths on different Windows drives - #3750

Closed
mikemikimike wants to merge 3 commits into
pre-commit:mainfrom
mikemikimike:fix/issue-2530-cross-drive-config
Closed

Handle config paths on different Windows drives#3750
mikemikimike wants to merge 3 commits into
pre-commit:mainfrom
mikemikimike:fix/issue-2530-cross-drive-config

Conversation

@mikemikimike

Copy link
Copy Markdown

Fixes #2530.

Background

When the config file is on a different Windows drive than the Git repository, os.path.relpath raises ValueError after pre-commit changes into the repository root. This prevents commands using an absolute config path from running.

Changes

Keep the absolute config path when it cannot be made relative to the repository. Same-drive and relative config behavior is unchanged. A regression test covers the cross-drive failure path.

Validation

  • python -m pytest tests/main_test.py -q --basetemp D:\\project\\tscodex\\github_pr\\tasks\\precommit-2530-basetemp — 30 passed.
  • python -m ruff check pre_commit/main.py tests/main_test.py — passed.
  • git diff --check — passed.

The broader test suite was not collected because the local environment lacks the repository development dependency re_assert; collection stopped in four test modules before execution.

@asottile asottile closed this Aug 29, 2026
@pre-commit pre-commit locked as spam and limited conversation to collaborators Aug 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

ValueError on Windows when config is on a different drive than the git repo

2 participants