blob: 1c358f7fe2b62914893589945a34f92758bde46a [file] [log] [blame]
Ming Zhao13145702015-07-07 16:30:59 +00001#!/bin/bash
2
3# This script will be run bazel when building process starts to
4# generate key-value information that represents the status of the
5# workspace. The output should be like
6#
7# KEY1 VALUE1
8# KEY2 VALUE2
9#
10# If the script exits with non-zero code, it's considered as a failure
11# and the output will be discarded.
12
13# The code below presents an implementation that works for git repository
14git_rev=$(git rev-parse HEAD)
15if [[ $? != 0 ]];
16then
17 exit 1
18fi
19echo "BUILD_SCM_REVISION ${git_rev}"
20
21# Check whether there are any uncommited changes
22git diff-index --quiet HEAD --
23if [[ $? == 0 ]];
24then
25 tree_status="Clean"
26else
27 tree_status="Modified"
28fi
29echo "BUILD_SCM_STATUS ${tree_status}"