build_nim.sh: deal with old local branches used as Nim targets (#23)

This commit is contained in:
Ștefan Talpalaru 2021-07-30 01:12:26 +02:00 committed by GitHub
parent a1da1f403d
commit 0e709abc28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -68,6 +68,9 @@ nim_needs_rebuilding() {
git fetch --all git fetch --all
git checkout -q ${NIM_COMMIT} git checkout -q ${NIM_COMMIT}
fi fi
# In case NIM_COMMIT is a local branch that's behind the remote one it's tracking.
git pull -q 2>/dev/null || true
git checkout -q ${NIM_COMMIT}
# We can't use "rev-parse" here, because it would return the tag object's # We can't use "rev-parse" here, because it would return the tag object's
# hash instead of the commit hash, when NIM_COMMIT is a tag. # hash instead of the commit hash, when NIM_COMMIT is a tag.
NIM_COMMIT_HASH="$(git rev-list -n 1 ${NIM_COMMIT})" NIM_COMMIT_HASH="$(git rev-list -n 1 ${NIM_COMMIT})"