beacon-node-builds: don't fetch if we're on a detached head

Causes failures when a tag is checked out, nothing to fetch.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2021-02-04 23:47:59 +01:00
parent 33ba3b1e8b
commit 8e0966fb0e
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 14 additions and 4 deletions

View File

@ -15,14 +15,24 @@ TAG="{{ item.name }}"
pushd repo
COMMIT_BEFORE=$(git rev-parse --short=8 HEAD)
# We cannot use "git pull" in here, because history may be changed upstream
git fetch
git reset --hard origin/{{ item.version }}
SYMBOLIC_NAME=$(git rev-parse --abbrev-ref --symbolic-full-name HEAD)
function headIsDetached() { [[ "${SYMBOLIC_NAME}" == "HEAD" ]]; }
# Detached HEAD means we're probably on a tag
if headIsDetached; then
echo "Deatached HEAD, nothing to fetch."
else
# We cannot use "git pull" in here, because history may be changed upstream
git fetch
git reset --hard origin/{{ item.version }}
fi
COMMIT_AFTER=$(git rev-parse --short=8 HEAD)
if [[ "$1" == "--force" ]]; then
echo "Forcing rebuild!"
elif [[ "${COMMIT_BEFORE}" == "${COMMIT_AFTER}" ]]; then
elif ! headIsDetached && [[ "${COMMIT_BEFORE}" == "${COMMIT_AFTER}" ]]; then
echo "Nothing new to build."
exit
fi