Skip to content

Add --remote flag to select which git remote to resolve#57

Merged
andrew merged 1 commit intomainfrom
remote-flag
Apr 13, 2026
Merged

Add --remote flag to select which git remote to resolve#57
andrew merged 1 commit intomainfrom
remote-flag

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented Apr 13, 2026

Closes #42.

forge previously hardcoded origin as the remote to read when figuring out which forge to talk to. With multiple remotes pointing at different forges (a Gitea origin and a GitHub mirror, say) there was no way to operate on the second one without -R owner/repo.

The new persistent --remote flag picks which remote URL to parse. Defaults to origin so existing behaviour is unchanged.

Implementation uses a package-level setter on internal/resolve called from PersistentPreRun, rather than threading a third parameter through the 75 identical resolve.Repo(flagRepo, flagForgeType) call sites. The remote name is session-wide state so this fits.

The git remote get-url lookup and URL parse are extracted into resolveRemote() so they can be tested without the network-touching client construction. Tests use a real temp git repo with two remotes — t.Chdir plus git init plus git remote add — and verify that switching the remote name produces a different domain.

Error messages now name which remote failed: reading remote "mirror" (not in a git repo, or remote not configured; use -R or --remote).

@andrew andrew merged commit 818dd54 into main Apr 13, 2026
4 checks passed
@andrew andrew deleted the remote-flag branch April 13, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specify remote for commands

1 participant