-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbazel-diff.sh
executable file
·51 lines (36 loc) · 1.6 KB
/
bazel-diff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -o errexit -o nounset -x
# Path to your Bazel WORKSPACE directory
workspace_path=$1
# Path to your Bazel executable
bazel_path=$2
# Starting Revision SHA
previous_revision=$(git -C $workspace_path rev-parse $3)
# Final Revision SHA
final_revision=$(git -C $workspace_path rev-parse $4)
starting_hashes_json="/tmp/starting_hashes.json"
final_hashes_json="/tmp/final_hashes.json"
impacted_targets_path="/tmp/impacted_targets.txt"
impacted_test_targets_path="/tmp/impacted_test_targets.txt"
# bazel_diff="/tmp/bazel_diff"
current_head=$(git -C $workspace_path rev-parse HEAD)
shared_flags=""
# Uncomment the line below to see debug information
# shared_flags="--config=verbose"
# $bazel_path run @bazel_diff//:bazel-diff $shared_flags --script_path="$bazel_diff"
git -C $workspace_path checkout $previous_revision --quiet
bazel_diff="$bazel_path run @bazel_diff//:bazel-diff"
echo "Generating Hashes for Revision '$previous_revision'"
${bazel_diff[@]} -- generate-hashes -w $workspace_path -b $bazel_path $starting_hashes_json
git -C $workspace_path checkout $final_revision --quiet
echo "Generating Hashes for Revision '$final_revision'"
${bazel_diff[@]} -- generate-hashes -w $workspace_path -b $bazel_path $final_hashes_json
echo "Determining Impacted Targets"
${bazel_diff[@]} -- -sh $starting_hashes_json -fh $final_hashes_json -w $workspace_path -b $bazel_path -o $impacted_targets_path
set +x
echo "----------------------"
echo "Impacted Targets between $previous_revision and $final_revision:"
cat $impacted_targets_path
echo ""
echo "----------------------"
git -C $workspace_path checkout "$current_head"