-
Notifications
You must be signed in to change notification settings - Fork 17
/
workspace_status.sh
executable file
·27 lines (23 loc) · 1.02 KB
/
workspace_status.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
#!/usr/bin/env bash
# This script is called by Bazel when it needs info about the git state.
# The --workspace_status_command flag tells Bazel the location of this script.
# This is configured in `/.bazelrc`.
set -o pipefail -o errexit -o nounset
function has_local_changes {
if [ "$(git status --porcelain)" != "" ]; then
echo dirty
else
echo clean
fi
}
# "volatile" keys, these will not cause a re-build because they're assumed to change on every build
# and its okay to use a stale value in a stamped binary
echo "BUILD_TIME $(date "+%Y-%m-%d %H:%M:%S %Z")"
# "stable" keys, should remain constant over rebuilds, therefore changed values will cause a
# rebuild of any stamped action that uses ctx.info_file or genrule with stamp = True
# Note, BUILD_USER is automatically available in the stable-status.txt, it matches $USER
echo "STABLE_BUILD_SCM_SHA $(git rev-parse HEAD)"
echo "STABLE_BUILD_SCM_LOCAL_CHANGES $(has_local_changes)"
if [ "$(git tag | wc -l)" -gt 0 ]; then
echo "STABLE_BUILD_SCM_TAG $(git describe --tags)"
fi