diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-28 10:06:32 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-28 10:06:32 +0300 |
| commit | 6743f5a85ed078818428609049c21ae11e1c6f5b (patch) | |
| tree | 37314519807f7005e7736271e01ff41d78775561 | |
| parent | dcf90064e3671d4eccc5f0f59182a4afe23c95f9 (diff) | |
fix(cli): restore exact forge host matching parity (dq)
| -rw-r--r-- | internal/cli/forge_client.go | 6 | ||||
| -rw-r--r-- | internal/cli/forge_client_test.go | 30 |
2 files changed, 33 insertions, 3 deletions
diff --git a/internal/cli/forge_client.go b/internal/cli/forge_client.go index 4d8eb60..690a6c8 100644 --- a/internal/cli/forge_client.go +++ b/internal/cli/forge_client.go @@ -8,11 +8,11 @@ import ( ) func newRepoClientForOrg(org config.Organization) (forge.RepoClient, bool) { - switch { - case org.IsGitHub(): + switch org.Host { + case "git@github.com": client := github.NewClient(org.GitHubToken, org.Name) return &client, true - case org.IsCodeberg(): + case "git@codeberg.org": client := codeberg.NewClient(org.Name, org.CodebergToken) return &client, true default: diff --git a/internal/cli/forge_client_test.go b/internal/cli/forge_client_test.go index 84f819b..9aff10b 100644 --- a/internal/cli/forge_client_test.go +++ b/internal/cli/forge_client_test.go @@ -49,4 +49,34 @@ func TestNewRepoClientForOrg(t *testing.T) { t.Fatal("expected nil client for unsupported host") } }) + + t.Run("unsupported near miss hosts", func(t *testing.T) { + t.Parallel() + + nearMissHosts := []string{ + "ssh://github.com", + "git@github.company.com", + "git@github.com:acme", + "https://codeberg.org", + "git@codeberg.org.example", + } + + for _, host := range nearMissHosts { + host := host + t.Run(host, func(t *testing.T) { + t.Parallel() + + client, ok := newRepoClientForOrg(config.Organization{ + Host: host, + Name: "acme", + }) + if ok { + t.Fatalf("expected unsupported host %q", host) + } + if client != nil { + t.Fatalf("expected nil client for unsupported host %q", host) + } + }) + } + }) } |
