Fix enable report host for entire:// mirror origins · Entire
Fix enable report host for entire:// mirror origins
02782a4→main ·
Soph·1mo ago·4 files·+63 added/-1 removed
cleanRemoteURLForReport rebuilt the reported URL from info.Host, which for an entire://cluster/gh/owner/repo origin (an already-mirrored repo) is the Entire cluster host, not github.com — so the backend got https://aws-us-east-2.entire.io/owner/repo.git and enable reporting silently failed for mirrored repos.
Add Info.CanonicalHost() to the gitremote package, derived from the existing hostToForge map, which maps the forge prefix back to its real host (gh -> github.com) and falls back to Host for unknown forges (self-hosted enterprise). Use it when building the reported URL.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
065aaa47aa4bView transcript
?\ Fix Enable Report Timeout and URL StrippingClaude Code·Opus 4.8[1m]·1 step
Changes
4
cmd/entire/cli
gitremote
Mgitremote.go+25
Mgitremote_test.go+24
Msetup.go+4/-1
Msetup_test.go+10
44 unmodified lines
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
44 unmodified lines
"github.com": "gh",
}
// forgeToHost is the reverse of hostToForge: it maps a forge identifier back to
// its canonical public host. Used to recover the real forge host from an
// entire:// remote, whose Host is the Entire cluster rather than the forge.
var forgeToHost = func() map[string]string {
m := make(map[string]string, len(hostToForge))
for host, forge := range hostToForge {
m[forge] = host
}
return m
}()
// CanonicalHost returns the canonical public host of the upstream forge.
//
// For direct git URLs this is just Host. For entire:// remotes — whose Host is
// the Entire cluster (e.g. aws-us-east-2.entire.io) rather than the forge — it
// maps the forge prefix back to the forge's host (gh → github.com). Falls back
// to Host when the forge is unknown (e.g. a self-hosted GitHub Enterprise),
// preserving the only host we know for it.
func (i *Info) CanonicalHost() string {
if host, ok := forgeToHost[i.Forge]; ok {
return host
}
return i.Host
}
// HostPort returns Host, or "Host:Port" when Port is non-empty.
func (i *Info) HostPort() string {
if i.Port == "" {
Mcmd/entire/cli/gitremote/gitremote.go+25
135 unmodified lines
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
135 unmodified lines
}
}
func TestInfo_CanonicalHost(t *testing.T) {
t.Parallel()
tests := []struct {
name string
url string
want string
}{
{"direct https github", "https://github.com/org/repo.git", "github.com"},
{"direct ssh github", "git@github.com:org/repo.git", "github.com"},
{"entire mirror maps forge to host", "entire://aws-us-east-2.entire.io/gh/org/repo", "github.com"},
{"unknown forge falls back to host", "git@ghe.corp.example.com:org/repo.git", "ghe.corp.example.com"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
info, err := ParseURL(tt.url)
require.NoError(t, err)
assert.Equal(t, tt.want, info.CanonicalHost())
})
}
}
func TestRedactURL(t *testing.T) {
t.Parallel()
Mcmd/entire/cli/gitremote/gitremote_test.go+24
979 unmodified lines
980
981
982
983
983
984
985
986
987
988
989
979 unmodified lines
if err != nil {
return "", fmt.Errorf("parse remote URL: %w", err)
}
return fmt.Sprintf("https://%s/%s/%s.git", info.Host, info.Owner, info.Repo), nil
// Use CanonicalHost, not Host: an entire://cluster/gh/owner/repo origin (an
// already-mirrored repo) carries the Entire cluster as Host, so reporting
// Host verbatim would point the backend at the cluster instead of github.com.
return fmt.Sprintf("https://%s/%s/%s.git", info.CanonicalHost(), info.Owner, info.Repo), nil
}
func newDisableCmd() *cobra.Command {
Mcmd/entire/cli/setup.go+4/-1
3128 unmodified lines
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3128 unmodified lines
rawURL: "https://github.com/entireio/cli",
want: "https://github.com/entireio/cli.git",
},
{
name: "entire:// mirror origin maps the forge back to its real host",
rawURL: "entire://aws-us-east-2.entire.io/gh/entireio/cli",
want: "https://github.com/entireio/cli.git",
},
{
name: "unknown forge host is preserved (self-hosted enterprise)",
rawURL: "git@ghe.corp.example.com:entireio/cli.git",
want: "https://ghe.corp.example.com/entireio/cli.git",
},
{
name: "unparseable single-segment path errors",
rawURL: "https://github.com/onlyowner.git",