diff options
author | Ming Zhao <mzhao@luminatewireless.com> | 2015-07-07 16:30:59 +0000 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@google.com> | 2015-07-08 11:40:42 +0000 |
commit | 1314570a4d9094c6157f8e1cfe4b31e61b01a1fb (patch) | |
tree | 7d97a9e95133f1f97883232959cf9f509b708eb1 /tools/buildstamp | |
parent | 5a9ec720d1224f1360fa2bf732a869a22c17afc1 (diff) |
Introduce hook to BazelWorkspaceStatusModule that calls external
script(controled by workspace_status_command option, default to
tools/buildstamp/get_workspace_status) to emit addtional workspace
information to stable-status.txt.
This should address #216.
--
Change-Id: Iffb06482489f0d55393e27b0764e6e127fedbc20
Reviewed-on: https://bazel-review.git.corp.google.com/#/c/1550
MOS_MIGRATED_REVID=97678871
Diffstat (limited to 'tools/buildstamp')
-rw-r--r-- | tools/buildstamp/BUILD | 8 | ||||
-rw-r--r-- | tools/buildstamp/get_workspace_status | 29 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tools/buildstamp/BUILD b/tools/buildstamp/BUILD new file mode 100644 index 0000000000..6ad7e59454 --- /dev/null +++ b/tools/buildstamp/BUILD @@ -0,0 +1,8 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "all", + srcs = [ + "get_workspace_status", + ], +) diff --git a/tools/buildstamp/get_workspace_status b/tools/buildstamp/get_workspace_status new file mode 100644 index 0000000000..1c358f7fe2 --- /dev/null +++ b/tools/buildstamp/get_workspace_status @@ -0,0 +1,29 @@ +#!/bin/bash + +# This script will be run bazel when building process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +# The code below presents an implementation that works for git repository +git_rev=$(git rev-parse HEAD) +if [[ $? != 0 ]]; +then + exit 1 +fi +echo "BUILD_SCM_REVISION ${git_rev}" + +# Check whether there are any uncommited changes +git diff-index --quiet HEAD -- +if [[ $? == 0 ]]; +then + tree_status="Clean" +else + tree_status="Modified" +fi +echo "BUILD_SCM_STATUS ${tree_status}" |