build.sh: Check status of all projects if checked out with `repo`
If the source tree was checked out with a `repo` manifest then the
cleanliness of the tree cannot be checked with a single `git status`.
This patch updates build.sh to check the status of all projects in the
manifest if the '.repo' folder exists.
Change-Id: If7fde5f5c180a77240599c25d271e24bc93c048b
diff --git a/kokoro/ubuntu/build.sh b/kokoro/ubuntu/build.sh
index 2b00b4d..0214a1f 100755
--- a/kokoro/ubuntu/build.sh
+++ b/kokoro/ubuntu/build.sh
@@ -17,6 +17,8 @@
SCRIPT_NAME="$(realpath "${BASH_SOURCE[0]}")"
ROOT_DIR="$(realpath $(dirname "${SCRIPT_NAME}")/../..)"
+REPO="${ROOT_DIR}/prebuilts/generic/repo/repo"
+
# Fail on any error.
set -e
# Fail on any part of a pipeline failing.
@@ -26,6 +28,19 @@
# Display commands being run.
set -x
+# Returns true if `git status` reports uncommitted changes in the source tree.
+function is_repo_dirty() {
+ local cmd=(git status --porcelain)
+ if [ -d ".repo" ]
+ then
+ # This source tree was checked out using `repo`. Check the
+ # status of all projects.
+ cmd=(${REPO} forall -c "${cmd[@]}")
+ fi
+ [[ $(${cmd[@]}) ]]
+ return $?
+}
+
# Default value of HAFNIUM_HERMETIC_BUILD is "true" for Kokoro builds.
if [ -v KOKORO_JOB_NAME -a ! -v HAFNIUM_HERMETIC_BUILD ]
then
@@ -98,7 +113,7 @@
#
make check
-if [[ `git status --porcelain` ]]
+if is_repo_dirty
then
echo "Run \`make check\' locally to fix this."
exit 1
@@ -109,7 +124,7 @@
#
make format
-if [[ `git status --porcelain` ]]
+if is_repo_dirty
then
echo "Run \`make format\' locally to fix this."
exit 1
@@ -122,7 +137,7 @@
#
make tidy
-if [[ `git status --porcelain` ]]
+if is_repo_dirty
then
echo "Run \`make tidy\' locally to fix this."
exit 1
@@ -133,7 +148,7 @@
#
make license
-if [[ `git status --porcelain` ]]
+if is_repo_dirty
then
echo "Run \`make license\' locally to fix this."
exit 1
diff --git a/prebuilts b/prebuilts
index 111f71d..d2f23ab 160000
--- a/prebuilts
+++ b/prebuilts
@@ -1 +1 @@
-Subproject commit 111f71d306f6c2fbfa075376524976305d9c93c4
+Subproject commit d2f23ab934ec1e0196240bef4829ad0a005afc68