Skip to content

Commit

Permalink
Fix label relativization
Browse files Browse the repository at this point in the history
  • Loading branch information
guw committed Dec 6, 2024
1 parent a0fd0f1 commit a3858bb
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,10 @@ public JavaSourceInfo getTestSourceInfo() {
* @return the passed in value or a relative path to a file in this package
*/
private String relativizeLabelToPackageIfPossible(String srcFileOrLabel) {
var myPackagePath = bazelPackage.getLabel().toString();

var relativePath = srcFileOrLabel;
var rootSlashIndex = srcFileOrLabel.indexOf(BazelLabel.BAZEL_ROOT_SLASHES);
if (rootSlashIndex > -1) {
relativePath = srcFileOrLabel.substring(rootSlashIndex + BazelLabel.BAZEL_ROOT_SLASHES.length());
}
if (relativePath.startsWith(myPackagePath + BazelLabel.BAZEL_COLON)) {
var myPackageLabel = bazelPackage.getLabel().toString();
if (srcFileOrLabel.startsWith(myPackageLabel + BazelLabel.BAZEL_COLON)) {
// drop the package name to identify a reference within package
return relativePath.substring(myPackagePath.length() + 1);
return srcFileOrLabel.substring(myPackageLabel.length() + 1);
}

// return original passed in value
Expand Down

0 comments on commit a3858bb

Please sign in to comment.