Skip to content

Commit 742b7ab

Browse files
Merge pull request #69 from Tinder/issue_61
Change in external repo not detected #61
2 parents 02586b1 + 5b13aa3 commit 742b7ab

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

.github/workflows/integration.yaml

-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ jobs:
1818
with:
1919
java-version: 1.8
2020
id: java
21-
- name: Setup Go environment
22-
uses: actions/setup-go@v2
23-
with:
24-
go-version: ^1.14
25-
id: go
26-
- name: Setup Bazelisk
27-
run: go get github.com/bazelbuild/bazelisk
2821
- uses: actions/checkout@v2
2922
- name: Run integration test
3023
run: ./integration/integration_test.sh -e
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Integration External Target
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
schedule:
9+
- cron: "0 */12 * * *"
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Setup Java JDK
17+
uses: actions/[email protected]
18+
with:
19+
java-version: 1.8
20+
id: java
21+
- uses: actions/checkout@v2
22+
with:
23+
repository: tinder-maxwellelliott/bazel-diff-repro-1
24+
ref: wip_fix
25+
fetch-depth: 0
26+
- name: Run External Target Impact test
27+
run: ./bazel-diff.sh $(pwd) bazel $(git rev-parse HEAD~1) $(git rev-parse HEAD)
28+
- name: Validate Impacted Targets
29+
run: grep -q "//:yo" /tmp/impacted_targets.txt
30+

src/main/java/com/bazel_diff/BazelRule.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.security.NoSuchAlgorithmException;
55
import java.util.List;
66
import com.google.devtools.build.lib.query2.proto.proto2api.Build;
7+
import java.util.stream.Collectors;
78

89
interface BazelRule {
910
byte[] getDigest() throws NoSuchAlgorithmException;
@@ -32,11 +33,26 @@ public byte[] getDigest() throws NoSuchAlgorithmException {
3233

3334
@Override
3435
public List<String> getRuleInputList() {
35-
return rule.getRuleInputList();
36+
return rule.getRuleInputList()
37+
.stream()
38+
.map(ruleInput -> transformRuleInput(ruleInput))
39+
.collect(Collectors.toList());
3640
}
3741

3842
@Override
3943
public String getName() {
4044
return rule.getName();
4145
}
46+
47+
private String transformRuleInput(String ruleInput) {
48+
if (ruleInput.startsWith("@")) {
49+
String[] splitRule = ruleInput.split("//");
50+
if (splitRule.length == 2) {
51+
String externalRule = splitRule[0];
52+
externalRule = externalRule.replaceFirst("@", "");
53+
return String.format("//external:%s", externalRule);
54+
}
55+
}
56+
return ruleInput;
57+
}
4258
}

0 commit comments

Comments
 (0)