Switch: acts only on a plan moving both engine and controller, and only for value 6 (issue 1942)
mesh/delivery delivered
mesh/check checking 44d9d4058253 on 34b105ea88df
mesh/delivery delivered
mesh/check checking 44d9d4058253 on 34b105ea88df
This commit is contained in:
@@ -50,10 +50,10 @@ type planOrder struct {
|
||||
}
|
||||
|
||||
// switchNamed says whether a pull request's description names release 6's switch: a line that is exactly the field
|
||||
// with a value.
|
||||
// with the value 6.
|
||||
func switchNamed(body string) bool {
|
||||
for _, line := range strings.Split(body, "\n") {
|
||||
if rest, ok := strings.CutPrefix(strings.TrimSpace(line), switchField); ok && strings.TrimSpace(rest) != "" {
|
||||
if rest, ok := strings.CutPrefix(strings.TrimSpace(line), switchField); ok && strings.TrimSpace(rest) == "6" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,8 @@ func orderEdges(moved []string, changes map[string]moduleChange, graph []invento
|
||||
var out planOrder
|
||||
sorted := append([]string(nil), moved...)
|
||||
sort.Strings(sorted)
|
||||
// The switch acts only on a plan that moves both the engine and the controller.
|
||||
switchNamed = switchNamed && slices.Contains(sorted, theController) && slices.Contains(sorted, theEngine)
|
||||
for _, server := range sorted {
|
||||
for _, caller := range sorted {
|
||||
if server == caller {
|
||||
@@ -123,10 +125,10 @@ func orderEdges(moved []string, changes map[string]moduleChange, graph []invento
|
||||
}
|
||||
}
|
||||
}
|
||||
if switchNamed && slices.Contains(sorted, theController) && slices.Contains(sorted, theEngine) {
|
||||
if switchNamed {
|
||||
overruled = append(overruled, ruleEngineFirst)
|
||||
}
|
||||
if switchNamed && slices.Contains(sorted, theController) {
|
||||
if switchNamed {
|
||||
out.Together = switchSaid(overruled)
|
||||
} else if slices.Contains(sorted, theController) && slices.Contains(sorted, theEngine) {
|
||||
all := orderingEdges(graph, out.Edges)
|
||||
|
||||
@@ -228,7 +228,17 @@ func TestTheSwitchSaysTheEdgesItOverruled(t *testing.T) {
|
||||
|
||||
// The switch is named by a line of a pull request's description.
|
||||
func TestTheSwitchIsNamedByAFieldOfTheDescription(t *testing.T) {
|
||||
if !switchNamed("Fixes 1\n\nRelease-switch: 6\n") || switchNamed("Release-switch:\n") || switchNamed("about the Release-switch: 6") {
|
||||
if !switchNamed("Fixes 1\n\nRelease-switch: 6\n") || switchNamed("Release-switch:\n") || switchNamed("Release-switch: 7") || switchNamed("about the Release-switch: 6") {
|
||||
t.Fatal("the field is not read as a line with a value")
|
||||
}
|
||||
}
|
||||
|
||||
// 1942/AC3: the switch acts only on a plan that moves the engine and the controller: without mesh-host the
|
||||
// version-skew edge stays, the line present or not.
|
||||
func TestTheSwitchWithoutTheEngineKeepsVersionSkew(t *testing.T) {
|
||||
changes := map[string]moduleChange{"app": {Manifest: true}}
|
||||
got := orderEdges([]string{"mesh-controller", "app"}, changes, nil, true)
|
||||
if e, ok := hasEdge(got.Edges, "app", "mesh-controller"); !ok || e.Why != "version skew" || got.Together != "" {
|
||||
t.Fatalf("version skew lost without the engine: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user