Skip to content
Myr

[Tests] install_nvm_from_git: don't fail when master is at the latest release tag

Before adoption: this commit came in with the history the project adopted, so no landing records it.

The avoid_ref check read HEAD's tags via `git for-each-ref` with no --git-dir, so it inspected the caller's checkout instead of the installed clone. Whether it passed then depended on which ref triggered the workflow (the same commit passed when built as the v0.40.6 tag but failed when built as master, since only the former had the tag present), not on the install result. Query the installed clone and compare commits, so a HEAD that is legitimately the latest release commit (eg master right after a release) is exempted deterministically.

authored by Jordan Harband · committed by Jordan Harband · parent b6cf55f · Browse files · 1 file+9 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−3 removed

  • tests:+9 added−3 removed

1 file+9 added−3 removed

modified:test/install_script/install_nvm_from_git+9 added-3 removed
61 unmodified lines
62 if [ -n "$ref" ]; then63 echo "$current_ref" | grep -q "$ref" || die "install_nvm_from_git ${message} did not clone with ref ${ref}"64 fi6566 local head_ref="$(git for-each-ref --points-at HEAD --format='%(refname:short)' 'refs/tags/')"67 if [ -n "${avoid_ref}" ] && [ "${head_ref}" != "${avoid_ref}" ]; then68 echo "${current_ref}" | grep -q "$avoid_ref" && die "install_nvm_from_git ${message} did clone with unwanted ref ${avoid_ref}"66 if [ -n "${avoid_ref}" ] && echo "${current_ref}" | grep -q "${avoid_ref}"; then67 # the avoided tag decorating HEAD is only legitimate if HEAD really is that68 # tag's commit in the installed clone (eg master released at that tag); query69 # the clone itself, not the caller's checkout, so the trigger ref cannot skew it70 local avoid_changeset71 avoid_changeset="$(git --git-dir "$NVM_DIR"/.git rev-parse --verify --quiet "refs/tags/${avoid_ref}^{commit}" 2>/dev/null)"72 if [ "${avoid_changeset}" != "${current_changeset}" ]; then73 die "install_nvm_from_git ${message} did clone with unwanted ref ${avoid_ref}"74 fi75 fi7677 if [ -n "$changeset" ]; then78 echo "${current_changeset}" | grep -q "${changeset}" || die "install_nvm_from_git ${message} did not clone with changeset ${changeset}"
60 unmodified lines