feat(gitutils): add parse_vcs_url for pip VCS URL parsing#1215
Conversation
Add `parse_vcs_url` to parse pip VCS URLs (git+https, git+ssh) into a repo clone URL and git ref. Use it in `bootstrapper` and `sources` to replace duplicated manual git+ URL parsing logic. Co-Authored-By: Claude <claude@anthropic.com> Signed-off-by: Christian Heimes <cheimes@redhat.com>
📝 WalkthroughWalkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_gitutils.py (1)
79-93: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover
#subdirectory=fragments in the parser tests.
parse_vcs_url()explicitly drops URL fragments before returning the clone URL, but this suite never exercises a pip-style#subdirectory=URL. That leaves a common VCS form unprotected against regressions in both callers.Suggested test addition
def test_parse_vcs_url() -> None: assert parse_vcs_url("git+https://git.test/org/project.git@v1.0") == ( "https://git.test/org/project.git", "v1.0", ) + assert parse_vcs_url( + "git+https://git.test/org/project.git@v1.0#subdirectory=src" + ) == ( + "https://git.test/org/project.git", + "v1.0", + ) # '@' in netloc must not be confused with the ref '@' assert parse_vcs_url("git+ssh://git@git.test/org/project.git@abc123") == ( "ssh://git@git.test/org/project.git", "abc123", )As per path instructions, "tests/**: Verify test actually tests the intended behavior. Check for missing edge cases."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_gitutils.py` around lines 79 - 93, Add a test case in test_parse_vcs_url() to cover a pip-style VCS URL with a `#subdirectory`= fragment, and assert that parse_vcs_url() still returns the cloned repo URL plus the correct ref while dropping the fragment. Use the existing parse_vcs_url and GIT_HEAD patterns in this test module so the new assertion verifies the fragment is ignored without changing the returned clone URL/ref behavior.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_gitutils.py`:
- Around line 79-93: Add a test case in test_parse_vcs_url() to cover a
pip-style VCS URL with a `#subdirectory`= fragment, and assert that
parse_vcs_url() still returns the cloned repo URL plus the correct ref while
dropping the fragment. Use the existing parse_vcs_url and GIT_HEAD patterns in
this test module so the new assertion verifies the fragment is ignored without
changing the returned clone URL/ref behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 41e8cbc8-5fc4-450a-a86b-b0796f44c7ae
📒 Files selected for processing (6)
src/fromager/bootstrapper.pysrc/fromager/gitutils.pysrc/fromager/sources.pytests/test_bootstrap.pytests/test_gitutils.pytests/test_sources.py
Pull Request Description
What
Add
parse_vcs_urlto parse pip VCS URLs (git+https, git+ssh) into a repo clone URL and git ref. Use it inbootstrapperandsourcesto replace duplicated manual git+ URL parsing logic.Why
Replace ad-hoc implementations of pip VCS url parsing with a single, well-designed, and reusable function.