summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-09 14:43:24 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-09 14:50:37 +0200
commite12ebb99e437fceb3195170f053908ec62cf32c3 (patch)
tree8e18be58c17850ac4478e28aac6a5564b120dbe6 /scripts
parent91404470d6a0eed17168c61c5402b16f3e0540e9 (diff)
osmo-clean-workspace.sh: make more robust against broken git clones
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/osmo-clean-workspace.sh29
1 files changed, 25 insertions, 4 deletions
diff --git a/scripts/osmo-clean-workspace.sh b/scripts/osmo-clean-workspace.sh
index fcbfea8..b67b548 100755
--- a/scripts/osmo-clean-workspace.sh
+++ b/scripts/osmo-clean-workspace.sh
@@ -28,16 +28,37 @@ git checkout -f HEAD
# Git automatically excludes subdirs that are git clones.
git clean -dxf
+git_clean() {
+ repos="$1"
+ if [ ! -d "$repos" ]; then
+ return
+ fi
+
+ if [ ! -d "$repos/.git" ]; then
+ echo "Not a git clone, removing: $repos"
+ rm -rf "$repos"
+ return
+ fi
+ if ! git -C "$repos" checkout -f HEAD; then
+ echo "Cleaning failed, removing: $repos"
+ rm -rf "$repos"
+ return
+ fi
+ if ! git -C "$repos" clean -dxf; then
+ echo "Cleaning failed, removing: $repos"
+ rm -rf "$repos"
+ return
+ fi
+}
+
# leave the deps checkouts around, to not clone entire git history every time,
# but clean each git of build artifacts.
if [ -d "$deps" ]; then
for dep_dir in "$deps"/* ; do
- git -C "$dep_dir" checkout -f HEAD
- git -C "$dep_dir" clean -dxf
+ git_clean "$dep_dir"
done
fi
if [ -d "layer1-headers" ]; then
- git -C "layer1-headers" checkout -f HEAD
- git -C "layer1-headers" clean -dxf
+ git_clean "layer1-headers"
fi