-
-
Notifications
You must be signed in to change notification settings - Fork 86
Fix relative repo paths to resolve from config file directory #1066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: j178 <[email protected]>
Co-authored-by: j178 <[email protected]>
|
@copilot Try to encapsulate the repo path normalize logic into the Project or RemoteHook, expose an function to get resolved clone url, then use that function in |
…o_url Co-authored-by: j178 <[email protected]>
Done! I've refactored the code to encapsulate the normalization logic in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1066 +/- ##
==========================================
- Coverage 89.82% 89.78% -0.04%
==========================================
Files 72 72
Lines 13294 13327 +33
==========================================
+ Hits 11941 11966 +25
- Misses 1353 1361 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fix: Relative Repo Paths Resolve from Config File Directory
Issue Summary
When a
.pre-commit-config.yamluses a relative repo path (e.g.,../hook-repo), the path was being resolved against the process' current working directory (CWD) instead of the directory containing the config file. This broke configs in subprojects that used relative paths to hook repositories.Solution
Implemented path normalization that resolves relative repository paths from the directory containing the
.pre-commit-config.yamlfile, as expected by users.Changes Made
Added
Project::resolve_repo_urlmethod (src/workspace.rs:221-243)Cow<str>for efficient borrowing when no normalization is neededUpdated
Project::init_repos(src/workspace.rs:258-305)resolve_repo_urlto get the resolved clone URLRemoteRepoonly when normalization occursUpdated
Workspace::init_repos(src/workspace.rs:770-821)resolve_repo_urlmethodDesign Improvements (addressing feedback)
Project::resolve_repo_urlTest Coverage
✅ All Tests Pass:
relative_repo_path_resolutionKey Design Decisions
Why check if path exists?
try-repowhich uses synthetic configsOriginal prompt
.pre-commit-config.yamlresolve from CWD instead of config file directory #1065💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.