-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): sync gazelle cli code to include latest fixes (#3913)
### Type of change - Bug fix (change which fixes an issue) - Chore (any other change that doesn't affect source or test files, such as configuration) ### Test plan - Covered by existing test cases - Manual testing; please provide instructions so we can reproduce: GitOrigin-RevId: 40732bccbda3ec783dcc3c01f889270bf588c698
- Loading branch information
1 parent
20fb2ad
commit 3eab48b
Showing
8 changed files
with
69 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copy of gazelle internal https://github.com/bazelbuild/bazel-gazelle/blob/b62589672b5c32264ddf40585247d684c29bdd15/internal/wspace/finder.go | ||
|
||
// Package wspace provides functions to locate and modify a bazel WORKSPACE file. | ||
package wspace | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
var workspaceFiles = []string{"WORKSPACE.bazel", "WORKSPACE"} | ||
|
||
// IsWORKSPACE checks whether path is named WORKSPACE or WORKSPACE.bazel | ||
func IsWORKSPACE(path string) bool { | ||
base := filepath.Base(path) | ||
for _, workspaceFile := range workspaceFiles { | ||
if base == workspaceFile { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
// FindWORKSPACEFile returns a path to a file in the provided root directory, | ||
// either to an existing WORKSPACE or WORKSPACE.bazel file, or to root/WORKSPACE | ||
// if neither exists. Note that this function does NOT recursively check parent directories. | ||
func FindWORKSPACEFile(root string) string { | ||
for _, workspaceFile := range workspaceFiles { | ||
path := filepath.Join(root, workspaceFile) | ||
if fileInfo, err := os.Stat(path); err == nil && !fileInfo.IsDir() { | ||
return path | ||
} | ||
} | ||
return filepath.Join(root, "WORKSPACE") | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters