forked from Tinder/bazel-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bazel-diff-example.sh
executable file
·39 lines (29 loc) · 1.25 KB
/
bazel-diff-example.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
#!/bin/bash
set -e
# Path to your Bazel WORKSPACE directory
workspace_path=$1
# Path to your Bazel executable
bazel_path=$2
# Starting Revision SHA
previous_revision=$3
# Final Revision SHA
final_revision=$4
starting_hashes_json="/tmp/starting_hashes.json"
final_hashes_json="/tmp/final_hashes.json"
impacted_targets_path="/tmp/impacted_targets.txt"
bazel_diff="/tmp/bazel_diff"
"$bazel_path" run :bazel-diff --script_path="$bazel_diff"
git -C "$workspace_path" checkout "$previous_revision" --quiet
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 get-impacted-targets -sh $starting_hashes_json -fh $final_hashes_json -o $impacted_targets_path
impacted_targets=()
IFS=$'\n' read -d '' -r -a impacted_targets < $impacted_targets_path || true
formatted_impacted_targets=$(IFS=$'\n'; echo "${impacted_targets[*]}")
echo "Impacted Targets between $previous_revision and $final_revision:"
echo "$formatted_impacted_targets"
echo ""