mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
build: fix check_generate not printing changed files (#33299)
Fixes an issue where HashFolder skipped the root directory upon hitting the first file in the excludes list. This happened because the walk function returned SkipDir even for regular files.
This commit is contained in:
parent
228933a660
commit
e58c785424
2 changed files with 15 additions and 9 deletions
11
build/ci.go
11
build/ci.go
|
|
@ -343,7 +343,7 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
|
|||
}
|
||||
ld = append(ld, "-extldflags", "'"+strings.Join(extld, " ")+"'")
|
||||
}
|
||||
// TODO(gballet): revisit after the input api has been defined
|
||||
// TODO(gballet): revisit after the input api has been defined
|
||||
if runtime.GOARCH == "wasm" {
|
||||
ld = append(ld, "-gcflags=all=-d=softfloat")
|
||||
}
|
||||
|
|
@ -462,9 +462,14 @@ func doCheckGenerate() {
|
|||
)
|
||||
pathList := []string{filepath.Join(protocPath, "bin"), protocGenGoPath, os.Getenv("PATH")}
|
||||
|
||||
excludes := []string{"tests/testdata", "build/cache", ".git"}
|
||||
for i := range excludes {
|
||||
excludes[i] = filepath.FromSlash(excludes[i])
|
||||
}
|
||||
|
||||
for _, mod := range goModules {
|
||||
// Compute the origin hashes of all the files
|
||||
hashes, err := build.HashFolder(mod, []string{"tests/testdata", "build/cache", ".git"})
|
||||
hashes, err := build.HashFolder(mod, excludes)
|
||||
if err != nil {
|
||||
log.Fatal("Error computing hashes", "err", err)
|
||||
}
|
||||
|
|
@ -474,7 +479,7 @@ func doCheckGenerate() {
|
|||
c.Dir = mod
|
||||
build.MustRun(c)
|
||||
// Check if generate file hashes have changed
|
||||
generated, err := build.HashFolder(mod, []string{"tests/testdata", "build/cache", ".git"})
|
||||
generated, err := build.HashFolder(mod, excludes)
|
||||
if err != nil {
|
||||
log.Fatalf("Error re-computing hashes: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,20 +21,21 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// HashFolder iterates all files under the given directory, computing the hash
|
||||
// of each.
|
||||
func HashFolder(folder string, exlude []string) (map[string][32]byte, error) {
|
||||
func HashFolder(folder string, excludes []string) (map[string][32]byte, error) {
|
||||
res := make(map[string][32]byte)
|
||||
err := filepath.WalkDir(folder, func(path string, d os.DirEntry, _ error) error {
|
||||
// Skip anything that's exluded or not a regular file
|
||||
for _, skip := range exlude {
|
||||
if strings.HasPrefix(path, filepath.FromSlash(skip)) {
|
||||
// Skip anything that's excluded or not a regular file
|
||||
if slices.Contains(excludes, path) {
|
||||
if d.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !d.Type().IsRegular() {
|
||||
return nil
|
||||
|
|
@ -71,6 +72,6 @@ func DiffHashes(a map[string][32]byte, b map[string][32]byte) []string {
|
|||
updates = append(updates, file)
|
||||
}
|
||||
}
|
||||
sort.Strings(updates)
|
||||
slices.Sort(updates)
|
||||
return updates
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue