@@ -20,6 +20,8 @@ import (
20
20
)
21
21
22
22
var workspaceFiles = []string {"WORKSPACE.bazel" , "WORKSPACE" }
23
+ // See https://bazel.build/versions/8.0.0/external/overview#repository
24
+ var repoBoundaryMarkerFiles = []string {"WORKSPACE.bazel" , "WORKSPACE" , "REPO.bazel" , "MODULE.bazel" }
23
25
24
26
// IsWORKSPACE checks whether path is named WORKSPACE or WORKSPACE.bazel
25
27
func IsWORKSPACE (path string ) bool {
@@ -45,7 +47,8 @@ func FindWORKSPACEFile(root string) string {
45
47
return filepath .Join (root , "WORKSPACE" )
46
48
}
47
49
48
- // FindRepoRoot searches from the given dir and up for a directory containing a WORKSPACE file
50
+ // FindRepoRoot searches from the given dir and up for a directory containing a "boundary marker file"
51
+ // which delimit a repository as of Bazel 8,
49
52
// returning the directory containing it, or an error if none found in the tree.
50
53
func FindRepoRoot (dir string ) (string , error ) {
51
54
dir , err := filepath .Abs (dir )
@@ -54,8 +57,8 @@ func FindRepoRoot(dir string) (string, error) {
54
57
}
55
58
56
59
for {
57
- for _ , workspaceFile := range workspaceFiles {
58
- filepath := filepath .Join (dir , workspaceFile )
60
+ for _ , boundaryFile := range repoBoundaryMarkerFiles {
61
+ filepath := filepath .Join (dir , boundaryFile )
59
62
info , err := os .Stat (filepath )
60
63
if err == nil && ! info .IsDir () {
61
64
return dir , nil
0 commit comments