From 934b4965e38517a6e1e87cd40725413d01faff90 Mon Sep 17 00:00:00 2001 From: Peter Woodman Date: Wed, 4 Dec 2024 19:18:14 -0500 Subject: [PATCH] fetch_repo: also remove WORKSPACE and MODULE files when cleaning --- cmd/fetch_repo/clean.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/fetch_repo/clean.go b/cmd/fetch_repo/clean.go index f5f0c625c..331661039 100644 --- a/cmd/fetch_repo/clean.go +++ b/cmd/fetch_repo/clean.go @@ -22,6 +22,15 @@ import ( ) func cleanBuildFiles(path string) error { + filenamesToClean := []string{ + "BUILD", + "BUILD.bazel", + "MODULE.bazel", + "MODULE.bazel.lock", + "WORKSPACE", + "WORKSPACE.bazel", + "WORKSPACE.bzlmod", + } return filepath.Walk(*dest, func(path string, info fs.FileInfo, err error) error { if err != nil { return err @@ -29,8 +38,10 @@ func cleanBuildFiles(path string) error { if info.IsDir() { return nil } - if info.Name() == "BUILD" || info.Name() == "BUILD.bazel" { - return os.Remove(path) + for _, filename := range filenamesToClean { + if info.Name() == filename { + return os.Remove(path) + } } return nil })