From 2b5e53fcd57409e018b468fd05eebad06fbff3fa Mon Sep 17 00:00:00 2001 From: Sladyn Nunes Date: Thu, 1 Apr 2021 19:06:40 +0530 Subject: [PATCH] [Fix] install script: check the proper version; fetch tags also Co-authored-by: Sladyn Nunes Co-authored-by: Jordan Harband --- test/install_script/install_nvm_from_git | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/install_script/install_nvm_from_git b/test/install_script/install_nvm_from_git index 161bbcb651..e5e391e6cd 100755 --- a/test/install_script/install_nvm_from_git +++ b/test/install_script/install_nvm_from_git @@ -55,14 +55,18 @@ test_install_data() { local ref="$4" local changeset="$5" local avoid_ref="$6" + if [ -n "$ref" ]; then - echo "$current_ref" | grep -q "$ref" || die "install_nvm_from_git $message did not clone with ref $ref" + echo "$current_ref" | grep -q "$ref" || die "install_nvm_from_git ${message} did not clone with ref ${ref}" fi - if [ -n "$avoid_ref" ]; then - echo "$current_ref" | grep -q "$avoid_ref" && die "install_nvm_from_git $message did clone with unwanted ref $avoid_ref" + + local head_ref="$(git for-each-ref --points-at HEAD --format='%(refname:short)' 'refs/tags/')" + if [ -n "${avoid_ref}" ] && [ "${head_ref}" != "${avoid_ref}"]; then + echo "${current_ref}" | grep -q "$avoid_ref" && die "install_nvm_from_git ${message} did clone with unwanted ref ${avoid_ref}" fi + if [ -n "$changeset" ]; then - echo "$current_changeset" | grep -q "$changeset" || die "install_nvm_from_git $message did not clone with changeset $changeset" + echo "${current_changeset}" | grep -q "${changeset}" || die "install_nvm_from_git ${message} did not clone with changeset ${changeset}" fi } @@ -73,7 +77,11 @@ test_install_data() { # - 4: changeset to check ("" if none) # - 5: ref to avoid ("" if none) test_install() { - NVM_INSTALL_VERSION="$1" + if [ -n "${1-}" ]; then + export NVM_INSTALL_VERSION="$1" + else + unset NVM_INSTALL_VERSION + fi local message="$2" local ref="$3" local changeset="$4"