in ibazel/workspace/workspace.go [35:66]
func (m *MainWorkspace) FindWorkspace() (string, error) {
path, err := os.Getwd()
if err != nil {
return "", err
}
volume := filepath.VolumeName(path)
for {
// filepath.Dir() includes a trailing separator if we're at the root
if path == volume+string(filepath.Separator) {
path = volume
}
// Check if we're at the workspace path
if _, err := os.Stat(filepath.Join(path, "WORKSPACE")); !os.IsNotExist(err) {
return path, nil
}
if _, err := os.Stat(filepath.Join(path, "WORKSPACE.bazel")); !os.IsNotExist(err) {
return path, nil
}
// If we've reached the root, then we know the cwd isn't within a workspace
if path == volume {
return "", errors.New("ibazel was not invoked from within a workspace\n")
}
// Move one level up the path
path = filepath.Dir(path)
}
}