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
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:
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user