@@ -7,12 +7,10 @@ import (
7
7
8
8
// FindWorkspaceRoot returns the root directory of the Bazel workspace in which the passed root exists, if any.
9
9
func 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
+ }
16
14
}
17
15
18
16
parentDirectory := filepath .Dir (root )
@@ -23,9 +21,9 @@ func FindWorkspaceRoot(root string) string {
23
21
return FindWorkspaceRoot (parentDirectory )
24
22
}
25
23
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
29
27
func isValidWorkspace (path string ) bool {
30
28
info , err := os .Stat (path )
31
29
if err != nil {
0 commit comments