@@ -7,12 +7,10 @@ import (
77
88// FindWorkspaceRoot returns the root directory of the Bazel workspace in which the passed root exists, if any.
99func FindWorkspaceRoot (root string ) string {
10- if isValidWorkspace (filepath .Join (root , "WORKSPACE" )) {
11- return root
12- }
13-
14- if isValidWorkspace (filepath .Join (root , "WORKSPACE.bazel" )) {
15- return root
10+ for _ , boundary := range [... ]string {"MODULE.bazel" , "REPO.bazel" , "WORKSPACE.bazel" , "WORKSPACE" } {
11+ if isValidWorkspace (filepath .Join (root , boundary )) {
12+ return root
13+ }
1614 }
1715
1816 parentDirectory := filepath .Dir (root )
@@ -23,9 +21,9 @@ func FindWorkspaceRoot(root string) string {
2321 return FindWorkspaceRoot (parentDirectory )
2422}
2523
26- // isValidWorkspace returns true iff the supplied path is the workspace root, defined by the presence of
27- // a file named WORKSPACE or WORKSPACE.bazel
28- // see https://github.com/bazelbuild/bazel/blob/8346ea4cfdd9fbd170d51a528fee26f912dad2d5 /src/main/cpp/workspace_layout.cc#L37
24+ // isValidWorkspace returns true if the supplied path is the workspace root, defined by the presence of
25+ // a file named MODULE.bazel, REPO.bazel, WORKSPACE.bazel, or WORKSPACE
26+ // see https://github.com/bazelbuild/bazel/blob/6.3.0 /src/main/cpp/workspace_layout.cc#L34
2927func isValidWorkspace (path string ) bool {
3028 info , err := os .Stat (path )
3129 if err != nil {
0 commit comments