Skip to content

Commit

Permalink
Fix condition check for label treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
guw committed Dec 10, 2024
1 parent a3858bb commit 23c2a28
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,19 @@ private boolean shouldTreatAsLabel(String srcFileOrLabel) {
* - starts with ':' (relative label) OR
* - starts with '@' or '//' OR
* - it does validate ok as label
* - AND it does not look like a path
* - AND no such a file exists
* OTHERWISE it is treated as file if:
* - it does look like a path OR
* - a file exists
*/

if (srcFileOrLabel.startsWith(BazelLabel.BAZEL_COLON)
|| srcFileOrLabel.startsWith(BazelLabel.BAZEL_ROOT_SLASHES)
|| srcFileOrLabel.startsWith(BazelLabel.BAZEL_EXTERNALREPO_AT)) {
|| srcFileOrLabel.startsWith(BazelLabel.BAZEL_EXTERNALREPO_AT)
|| (Label.validate(srcFileOrLabel) == null)) {
return true;
}

return (Label.validate(srcFileOrLabel) == null) && (srcFileOrLabel.indexOf('/') == -1)
return (srcFileOrLabel.indexOf('/') == -1)
&& !isRegularFile(bazelPackage.getLocation().append(new Path(srcFileOrLabel)).toPath());
}

Expand Down

0 comments on commit 23c2a28

Please sign in to comment.