Checker refuses a program a commit of the branch added and a later one removed: it stays in history (issue 1577)
This commit is contained in:
@@ -29,6 +29,10 @@ func (st *state) checkBinariesOf(t *target) verdictPtr {
|
|||||||
}
|
}
|
||||||
var found []string
|
var found []string
|
||||||
for _, p := range *t.fetched.Programs {
|
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)")
|
found = append(found, p.Path+": a compiled program is build output: remove it and add it to .gitignore (issue 1577)")
|
||||||
}
|
}
|
||||||
if len(found) > 0 {
|
if len(found) > 0 {
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ func TestAChangeWhoseFetchReportsProgramsFailsNamingEachFile(t *testing.T) { //
|
|||||||
prog := func(p ...string) *[]ProgramFile {
|
prog := func(p ...string) *[]ProgramFile {
|
||||||
out := []ProgramFile{}
|
out := []ProgramFile{}
|
||||||
for _, f := range p {
|
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
|
return &out
|
||||||
}
|
}
|
||||||
@@ -25,6 +26,7 @@ func TestAChangeWhoseFetchReportsProgramsFailsNamingEachFile(t *testing.T) { //
|
|||||||
{"none found", prog(), nil, false},
|
{"none found", prog(), nil, false},
|
||||||
{"one program", prog("modules/m/m"), []string{"modules/m/m"}, 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},
|
{"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},
|
{"an older build module reports nothing", nil, nil, true},
|
||||||
} {
|
} {
|
||||||
b := newBench(t)
|
b := newBench(t)
|
||||||
@@ -49,7 +51,11 @@ func TestAChangeWhoseFetchReportsProgramsFailsNamingEachFile(t *testing.T) { //
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, p := range c.fail {
|
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)
|
t.Errorf("%s: words %q do not name %s", c.name, v.Failed.Words, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ type Fetched struct {
|
|||||||
type ProgramFile struct {
|
type ProgramFile struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Kind string `json:"kind"`
|
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.
|
// GoPackage is one package of a Go test result.
|
||||||
|
|||||||
Reference in New Issue
Block a user