Repository navigation
fix(crs): re-point origin when a CRS entry's source.url changes - #577
Open
ParthMozarkar wants to merge 1 commit into
Open
ParthMozarkar wants to merge 1 commit into
ParthMozarkar wants to merge 1 commit into
Conversation
init_crs_repo() used repo_url only when cloning. The checkout lives at crs_src/<entry name>, keyed by name only, so after changing an entry's source.url (for example to a fork) the next prepare fetched and reset against the old origin and built the previous repository without any warning. When the checkout exists and its origin differs from source.url, run `git remote set-url origin <url>` before fetching and print a warning. Spellings of the same URL with or without a trailing '/' or '.git' count as unchanged. With --offline nothing can be fetched, so a mismatched checkout now fails with an error naming both URLs. Checkouts without an origin, unchanged URLs and skip_if_exists keep their previous behavior. Document checkout reuse and URL changes in crs-compose.md. Closes ossf#559 Signed-off-by: ParthMozarkar <greatparth21@gmail.com>
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
init_crs_repo()usedrepo_urlonly when cloning. The checkout lives atcrs_src/<entry name>, keyed by name only, so after changing an entry'ssource.url(e.g. to a fork) the nextpreparefetched and reset against the oldoriginand built the previous repository, with no warning.Now, when the checkout exists and its
origindiffers fromsource.url:git remote set-url origin <url>runs before the fetch, and a warning is printed--offline: fails with an error naming both URLs, since the new repository can't be fetchedURLs that differ only by a trailing
/or.gitare treated as unchanged. Checkouts with noorigin, unchanged URLs, andskip_if_existskeep their previous behavior. The new block sits after the existing task selection, so it doesn't touch the lines #497 changes; I checked that this branch and #497 merge cleanly.User Impact
Changing
source.urlfor an existing CRS entry now takes effect on the next run.docs/config/crs-compose.mdexplains checkout reuse and URL changes. No config or CLI changes; no migration needed.Release Note / Changelog
CHANGELOG.md([Unreleased]) for user-facing changesValidation
Added
oss_crs/tests/unit/test_crs_source_url.py(13 tests; 4 failed before the fix). End-to-end tests use two real local repositories, as in the issue's repro:origin= Bset-url--offlinewith a changed URL: fails, checkout stays on AGit Set Remote URLbeforeGit Fetchonly when the URL changed.git/ trailing-slash spellings are not treated as a changeoriginandskip_if_existsbehave as beforeThe existing
test_offline_flag.pytests pass unchanged.uv run verify: all checks pass (ruff check, ruff format, pyright, unit tests, libCRS unit tests).Checklist
Closes #559