Fix edge case around "bashbrew from" failing to create Git cache

This commit is contained in:
Tianon Gravi 2021-12-01 12:03:30 -08:00
parent 7d8e6d56ac
commit 875dcb4f08
1 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,10 @@ eval "${GENERATE_STACKBREW_LIBRARY:-./generate-stackbrew-library.sh}" > "$BASHBR
# if we don't appear to be able to fetch the listed commits, they might live in a PR branch, so we should force them into the Bashbrew cache directly to allow it to do what it needs
if ! bashbrew from "$image" &> /dev/null; then
bashbrewGit="${BASHBREW_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/bashbrew}/git"
if [ ! -d "$bashbrewGit" ]; then
# if we're here, it's because "bashbrew from" failed so our cache directory might not have been created
bashbrew from https://github.com/docker-library/official-images/raw/HEAD/library/hello-world:latest > /dev/null
fi
git -C "$bashbrewGit" fetch --quiet --update-shallow "$PWD" HEAD > /dev/null
bashbrew from "$image" > /dev/null
fi