From d74e0821552ce67eca7fc41887f81d2c2b10cf2c Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 26 Oct 2026 19:47:53 +0100 Subject: [PATCH] Checker refuses a program a commit of the branch added and a later one removed: it stays in history (issue 1577) --- .../mesh-delivery-checker/internal/check/binaries.go | 4 ++++ .../internal/check/binaries_test.go | 10 ++++++++-- .../mesh-delivery-checker/internal/check/results.go | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-checker/internal/check/binaries.go b/modules/mesh-delivery-checker/internal/check/binaries.go index c81dd29..5329c61 100644 --- a/modules/mesh-delivery-checker/internal/check/binaries.go +++ b/modules/mesh-delivery-checker/internal/check/binaries.go @@ -29,6 +29,10 @@ func (st *state) checkBinariesOf(t *target) verdictPtr { } var found []string for _, p := range *t.fetched.Programs { + if p.Commit != "" { + found = append(found, fmt.Sprintf("%s: a compiled program added in %s and removed later: it stays in history; squash the branch (issue 1577)", p.Path, short12(p.Commit))) + continue + } found = append(found, p.Path+": a compiled program is build output: remove it and add it to .gitignore (issue 1577)") } if len(found) > 0 { diff --git a/modules/mesh-delivery-checker/internal/check/binaries_test.go b/modules/mesh-delivery-checker/internal/check/binaries_test.go index 6b9c3b4..2a3ab5e 100644 --- a/modules/mesh-delivery-checker/internal/check/binaries_test.go +++ b/modules/mesh-delivery-checker/internal/check/binaries_test.go @@ -12,7 +12,8 @@ func TestAChangeWhoseFetchReportsProgramsFailsNamingEachFile(t *testing.T) { // prog := func(p ...string) *[]ProgramFile { out := []ProgramFile{} for _, f := range p { - out = append(out, ProgramFile{Path: f, Kind: "ELF"}) + path, commit, _ := strings.Cut(f, "@") // `path@commit`: added by a commit of the branch and removed later + out = append(out, ProgramFile{Path: path, Kind: "ELF", Commit: commit}) } return &out } @@ -25,6 +26,7 @@ func TestAChangeWhoseFetchReportsProgramsFailsNamingEachFile(t *testing.T) { // {"none found", prog(), nil, false}, {"one program", prog("modules/m/m"), []string{"modules/m/m"}, false}, {"two programs", prog("a/x", "b/y"), []string{"a/x", "b/y"}, false}, + {"added and removed in the branch", prog("gone/prog@0123456789abcdef0123"), []string{"gone/prog: a compiled program added in 0123456789ab and removed later: it stays in history; squash the branch (issue 1577)"}, false}, {"an older build module reports nothing", nil, nil, true}, } { b := newBench(t) @@ -49,7 +51,11 @@ func TestAChangeWhoseFetchReportsProgramsFailsNamingEachFile(t *testing.T) { // continue } for _, p := range c.fail { - if !strings.Contains(v.Failed.Words, p+": a compiled program is build output: remove it and add it to .gitignore (issue 1577)") { + want := p + if !strings.Contains(p, " added in ") { + want = p + ": a compiled program is build output: remove it and add it to .gitignore (issue 1577)" + } + if !strings.Contains(v.Failed.Words, want) { t.Errorf("%s: words %q do not name %s", c.name, v.Failed.Words, p) } } diff --git a/modules/mesh-delivery-checker/internal/check/results.go b/modules/mesh-delivery-checker/internal/check/results.go index bc5e523..12597a7 100644 --- a/modules/mesh-delivery-checker/internal/check/results.go +++ b/modules/mesh-delivery-checker/internal/check/results.go @@ -53,6 +53,8 @@ type Fetched struct { type ProgramFile struct { Path string `json:"path"` Kind string `json:"kind"` + // Commit is set for a program a commit of the branch added and a later one removed: it stays in history once merged. + Commit string `json:"commit,omitempty"` } // GoPackage is one package of a Go test result.