Fix stale remote URL when cached repo's origin changes#298
Merged
hasaant merged 1 commit intoMar 27, 2026
Merged
Conversation
When a GitHub repo is transferred between orgs (e.g. wayfair-staging to wayfair-shared), the locally cached clone retains the old origin URL. Subsequent calls to get_updated_repo() would fail with "repository not found" because fetch/pull still targets the stale URL. Compare the cached origin URL against the caller-provided repo_url and call set_url() to update it before fetching. Fixes SRVLC-2064
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #298 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 7 +1
Lines 173 176 +3
Branches 20 16 -4
=========================================
+ Hits 173 176 +3
🚀 New features to boost your workflow:
|
jashparekh
approved these changes
Mar 27, 2026
jashparekh
left a comment
Contributor
There was a problem hiding this comment.
LGTM! This is a clean fix with excellent test coverage. The implementation correctly handles the stale remote URL scenario when repos are transferred between orgs.
3 tasks
hasaant
pushed a commit
to hasaant/pygitops
that referenced
this pull request
Apr 6, 2026
Resolve conflicts: - setup.cfg: accept deletion (project uses pyproject.toml on main) - tests/test_operations.py: drop duplicate tests already present from wayfair-incubator#298 Made-with: Cursor
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
When a GitHub repo is transferred between orgs (e.g.
wayfair-staging→wayfair-shared), the locally cached clone retains the old origin URL. Subsequent calls toget_updated_repo()fail withrepository not foundbecausefetch/pullstill target the stale URL.This adds a URL comparison in
get_updated_repo(): if the cachedorigin.urldoesn't match the caller-providedrepo_url, we callset_url()to update it before any fetch operations.Changes
pygitops/operations.py: Comparerepo.remotes.origin.urlagainst the passedrepo_urland callset_url()when they differ, before fetching or pullingtests/test_operations.py: Added 3 new tests:set_urlset_urlget_updated_repoupdates the URL and pulls new contentTest plan
set_urlis called only when URLs differ