From 40b7e1d0b8d478d14a6ec4eec1a0a4f60a4ac2a3 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Sun, 30 May 2021 19:01:43 +0000 Subject: [PATCH] Cirrus: Tolerate missing projects when unpacking Git --- tools/cirrus_unpack_git.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/cirrus_unpack_git.sh b/tools/cirrus_unpack_git.sh index bb57e75..5f93121 100755 --- a/tools/cirrus_unpack_git.sh +++ b/tools/cirrus_unpack_git.sh @@ -5,6 +5,16 @@ shopt -s failglob for PROJECT in ./git_index/* do - PROJECT_BASE=$(basename $PROJECT) - mv ${PROJECT} ./git_clones/${PROJECT_BASE}/.git/index + PROJECT_BASE="$(basename $PROJECT)" + + # It's possible that the cache contains a project that was removed from the + # build sometime after the cache was saved. In such a case, unpacking it + # would result in "No such file or directory", so we just discard it + # instead. + if [[ -d "./git_clones/${PROJECT_BASE}/.git" ]] + then + mv "${PROJECT}" "./git_clones/${PROJECT_BASE}/.git/index" + else + rm "${PROJECT}" + fi done