Skip to content

Commit

Permalink
Change in external repo not detected #61
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-maxwellelliott committed Jun 9, 2021
1 parent 02586b1 commit 2fa46bb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/com/bazel_diff/BazelRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.List;
import com.google.devtools.build.lib.query2.proto.proto2api.Build;
import java.util.stream.Collectors;

interface BazelRule {
byte[] getDigest() throws NoSuchAlgorithmException;
Expand Down Expand Up @@ -32,11 +33,26 @@ public byte[] getDigest() throws NoSuchAlgorithmException {

@Override
public List<String> getRuleInputList() {
return rule.getRuleInputList();
return rule.getRuleInputList()
.stream()
.map(ruleInput -> transformRuleInput(ruleInput))
.collect(Collectors.toList());
}

@Override
public String getName() {
return rule.getName();
}

private String transformRuleInput(String ruleInput) {
if (ruleInput.startsWith("@")) {
String[] splitRule = ruleInput.split("//");
if (splitRule.length == 2) {
String externalRule = splitRule[0];
externalRule = externalRule.replaceFirst("@", "");
return String.format("//external:%s", externalRule);
}
}
return ruleInput;
}
}

0 comments on commit 2fa46bb

Please sign in to comment.