Name a repository in the facts as owner/repository, without the forge's address
mesh/merge-gate error: builds build-agent, mesh-controller, route-proxy → ace, g14, novox, shanks; no bus step; the check could not run: a throwaway postgr…
mesh/repo-check error: the check could not run: a throwaway postgres:17-alpine could not be raised: docker run --label mesh.build=build-1791331512096605198…
mesh/delivery superseded: a newer head of the same pull request

The snapshot promises no address, and every module's repository, reads and sources carried the URL the
mesh clones from. A check matches repositories by owner and name, so nothing it reads is lost (novox/hq
issue 288).
This commit is contained in:
jochen
2026-10-07 02:04:35 +02:00
parent b39eaa485a
commit 3d7ccc8aeb
3 changed files with 47 additions and 3 deletions
+15
View File
@@ -172,3 +172,18 @@ func TestAWithheldPathStaysAPath(t *testing.T) {
t.Errorf("a key became %q", got)
}
}
// **Issue 288**: a repository was kept as the URL it was cloned from, the forge's address with it.
func TestARepositoryIsNamedWithoutTheForge(t *testing.T) {
for in, want := range map[string]string{
"http://forge.internal:3000/owner/repo.git": "owner/repo",
"ssh://git@forge.internal:222/owner/repo": "owner/repo",
"git@forge.internal:owner/repo.git": "owner/repo",
"owner/repo": "owner/repo",
"": "",
} {
if got := RepositoryName(in); got != want {
t.Errorf("%q is named %q, not %q", in, got, want)
}
}
}
+28
View File
@@ -321,3 +321,31 @@ func standIn(run string) string {
}
return run
}
// RepositoryName is a repository as `owner/repository`, without the forge's address it was cloned from:
// http://forge.internal:3000/owner/repo.git → owner/repo (novox/hq issue 288). What a check matches a
// pull request's repository by is its owner and name, never the forge's address, so nothing is lost.
func RepositoryName(repository string) string {
r := strings.TrimSuffix(strings.TrimSuffix(strings.TrimSpace(repository), "/"), ".git")
if r == "" {
return ""
}
if _, rest, found := strings.Cut(r, "://"); found {
r = rest
if _, path, found := strings.Cut(r, "/"); found {
r = path
} else {
return ""
}
} else if at := strings.Index(r, "@"); at >= 0 {
// scp-like: git@forge:owner/repo
if _, path, found := strings.Cut(r[at+1:], ":"); found {
r = path
}
}
parts := strings.Split(strings.Trim(r, "/"), "/")
if len(parts) >= 2 {
return parts[len(parts)-2] + "/" + parts[len(parts)-1]
}
return parts[len(parts)-1]
}