Skip to content

Honor --host when resolving the repo from the git remote - #183

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
orshih6:contribot/issue-176
Oct 21, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
orshih6:contribot/issue-176

Conversation

@orshih6

@orshih6 orshih6 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

When no --repo was given, resolve.Repo read the git remote and built the forge client for the remote's domain. It ignored --host, even though the flag's help text says it overrides remote detection. So in a repo whose only remote is a self-hosted Gitea, forge --host github.com release create ... (and repo view, and every other command that resolves the current repo) still went to the Gitea instance.

Now repoFromGitRemote uses the --host domain when one is set and keeps the owner/repo parsed from the remote. Commands that pass --repo are unchanged, and so is the behaviour when --host isn't given. FORGE_HOST is deliberately left alone: it still doesn't override an explicit remote, so people who set it globally see no change.

Testing: added TestRepoFromGitRemoteHostOverride. It creates a temp git repo whose origin is on git.selfhosted.test, sets --host github.com, and checks that Repo("", "") returns domain github.com with owner/repo someone/project. Without the fix the test fails because it tries to probe the self-hosted domain; with the fix it passes. go test ./internal/resolve/ ./internal/cli/ passes, and gofmt and go vet are clean.

🤖 Generated with Claude Code

Fixes #176


This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like.

@andrew
andrew merged commit be92297 into git-pkgs:main Oct 21, 2026
5 checks passed
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.

--forge flag ignored when repo auto-detection occurs

2 participants