33 lines
1.5 KiB
Go
33 lines
1.5 KiB
Go
package check
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// A change that adds or modifies a compiled program fails (issue 1577): it is build output, `go build` in a module's folder
|
|
// writes one beside go.mod, and `git add -A` takes it. The build module's fetch step, which holds the merged clone, reads the
|
|
// first bytes of each changed file and reports the programs (the build modules' fetch tools); the checker judges the answer.
|
|
|
|
// checkBinariesOf fails a pull request whose change adds or modifies a compiled program, naming each file. It judges the
|
|
// first fetch answer of the pull request, whichever build module gave it. A fetch that made the merge and names no program has
|
|
// none: the answer's `programs` is an omitted empty list (B2g), and `merge` tells a preview was made.
|
|
func (st *state) checkBinariesOf(t *target) verdictPtr {
|
|
key := fmt.Sprintf("%s#%d", t.pull.Repository, t.pull.Number)
|
|
if t.fetched.Merge == "" {
|
|
return nil // no merge was made: nothing was changed to judge
|
|
}
|
|
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 {
|
|
return failed(t.node, fmt.Sprintf("%s: %s", key, strings.Join(found, "; ")))
|
|
}
|
|
return nil
|
|
}
|