Say a placeholder or replaced mesh-sdk pin as a local mesh-sdk, not as a version
mesh/merge-gate head 8a330afd44ba merged into trunk 6c2a8d62100c — pass: builds build-agent, mesh-controller, route-proxy → ace, g14, novox, shanks; no bus…
mesh/repo-check head 8a330afd44ba merged into trunk 6c2a8d62100c — pass: its merge-check.sh passed
mesh/delivery delivered
mesh/merge-gate head 8a330afd44ba merged into trunk 6c2a8d62100c — pass: builds build-agent, mesh-controller, route-proxy → ace, g14, novox, shanks; no bus…
mesh/repo-check head 8a330afd44ba merged into trunk 6c2a8d62100c — pass: its merge-check.sh passed
mesh/delivery delivered
This commit is contained in:
+30
-13
@@ -1637,35 +1637,52 @@ func dialable(ctx context.Context, address string) error {
|
||||
return fmt.Errorf("nothing took a connection at %s", address)
|
||||
}
|
||||
|
||||
// sdkPin is the mesh-sdk version the controller in dir takes (its go.mod's go requirement), or "" when it names none.
|
||||
func sdkPin(dir string) string {
|
||||
// sdkPin is the mesh-sdk version the controller in dir takes (its go.mod's go requirement), or "" when it names none; and
|
||||
// local says that version is no real one: the placeholder v0.0.0, or a replace of mesh-sdk by a directory, which a
|
||||
// workspace or a fixture uses and no release holds.
|
||||
func sdkPin(dir string) (version string, local bool) {
|
||||
body, err := os.ReadFile(filepath.Join(dir, "go.mod"))
|
||||
if err != nil {
|
||||
return ""
|
||||
return "", false
|
||||
}
|
||||
const path = "git.novox.be/novox/mesh-sdk/go"
|
||||
replaced := false
|
||||
for _, line := range strings.Split(string(body), "\n") {
|
||||
f := strings.Fields(strings.TrimPrefix(strings.TrimSpace(line), "require "))
|
||||
if len(f) >= 2 && f[0] == "git.novox.be/novox/mesh-sdk/go" {
|
||||
return f[1]
|
||||
f := strings.Fields(strings.TrimPrefix(strings.TrimPrefix(strings.TrimSpace(line), "require "), "replace "))
|
||||
switch {
|
||||
case len(f) >= 3 && f[0] == path && f[len(f)-2] == "=>" && (strings.HasPrefix(f[len(f)-1], ".") || strings.HasPrefix(f[len(f)-1], "/")):
|
||||
replaced = true
|
||||
case len(f) >= 2 && f[0] == path && version == "" && f[1] != "=>":
|
||||
version = f[1]
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return version, version == "v0.0.0" || (replaced && version != "")
|
||||
}
|
||||
|
||||
// validatorAt names the validator of the controller in dir as mesh-sdk's at that controller's pin (issue 1391).
|
||||
// validatorAt names the validator of the controller in dir as mesh-sdk's at that controller's pin (issue 1391): the
|
||||
// version when it is a real one, and a local mesh-sdk said as such when it is not.
|
||||
func validatorAt(dir string) string {
|
||||
if v := sdkPin(dir); v != "" {
|
||||
switch v, local := sdkPin(dir); {
|
||||
case v == "":
|
||||
return "mesh-sdk's validator at the controller's pin"
|
||||
case local:
|
||||
return "mesh-sdk's validator from a local mesh-sdk (" + v + ", replaced)"
|
||||
default:
|
||||
return "mesh-sdk's validator at " + v
|
||||
}
|
||||
return "mesh-sdk's validator at the controller's pin"
|
||||
}
|
||||
|
||||
// pinNote is the version of that pin, for a sentence that already says "the pin of": ", " and the version, or nothing.
|
||||
// pinNote is the pin for a sentence that already says "the pin of": the version in brackets when it is a real one, a
|
||||
// local mesh-sdk said as such when it is not, or nothing.
|
||||
func pinNote(dir string) string {
|
||||
if v := sdkPin(dir); v != "" {
|
||||
switch v, local := sdkPin(dir); {
|
||||
case v == "":
|
||||
return ""
|
||||
case local:
|
||||
return " (a local mesh-sdk, " + v + ", replaced)"
|
||||
default:
|
||||
return " (" + v + ")"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// judge builds the controller that judges a change: the one the mesh runs, beside the check as
|
||||
|
||||
Reference in New Issue
Block a user