diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-10-30 21:31:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-30 21:31:32 +0100 |
commit | 45e0bd3891f96aed251cc3bbc99b3d16bfc7b8ab (patch) | |
tree | f1403db49270c962d16ba660dcaaa6ed6ee328e6 /contrib/cirrus/lib.sh | |
parent | 32266d155fe156ef562d8fed27112d5644fd8c77 (diff) | |
parent | 326ef19d942c8922ebba68e96d870d5117f67472 (diff) | |
download | podman-45e0bd3891f96aed251cc3bbc99b3d16bfc7b8ab.tar.gz podman-45e0bd3891f96aed251cc3bbc99b3d16bfc7b8ab.tar.bz2 podman-45e0bd3891f96aed251cc3bbc99b3d16bfc7b8ab.zip |
Merge pull request #4379 from cevich/fix_upload_release_archive
Cirrus: Fix upload_release_archive on branch or tag
Diffstat (limited to 'contrib/cirrus/lib.sh')
-rw-r--r-- | contrib/cirrus/lib.sh | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index 051157702..297ed49ce 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -238,34 +238,46 @@ ircmsg() { # there is at least one release tag not having any '-' characters (return 0) # or otherwise (return non-0). is_release() { - req_env_var CIRRUS_BASE_SHA CIRRUS_CHANGE_IN_REPO - local range="${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}" - # Easy check first, default non-useful values - if echo "${range}$CIRRUS_TAG" | grep -iq 'unknown'; then - die 11 "is_release() unusable range ${range} or tag $CIRRUS_TAG" - fi - # Next easy check, is CIRRUS_TAG set unset RELVER + local ret + req_env_var CIRRUS_CHANGE_IN_REPO if [[ -n "$CIRRUS_TAG" ]]; then RELVER="$CIRRUS_TAG" - else # Lastly, look through the range for tags - git fetch --all --tags &> /dev/null|| \ - die 12 "is_release() failed to fetch tags" - RELVER=$(git log --pretty='format:%d' $range | \ - grep '(tag:' | sed -r -e 's/\s+[(]tag:\s+(v[0-9].*)[)]/\1/' | \ - sort -uV | tail -1) - [[ "$?" -eq "0" ]] || \ + elif [[ ! "$CIRRUS_BASE_SHA" =~ "unknown" ]] + then + # Normally not possible for this to be empty, except when unittesting. + req_env_var CIRRUS_BASE_SHA + local range="${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}" + if echo "${range}$CIRRUS_TAG" | grep -iq 'unknown'; then + die 11 "is_release() unusable range ${range} or tag $CIRRUS_TAG" + fi + + if type -P git &> /dev/null + then + git fetch --all --tags &> /dev/null|| \ + die 12 "is_release() failed to fetch tags" + RELVER=$(git log --pretty='format:%d' $range | \ + grep '(tag:' | sed -r -e 's/\s+[(]tag:\s+(v[0-9].*)[)]/\1/' | \ + sort -uV | tail -1) + ret=$? + else + warn -1 "Git command not found while checking for release" + ret="-1" + fi + [[ "$ret" -eq "0" ]] || \ die 13 "is_release() failed to parse tags" + else # Not testing a PR, but neither CIRRUS_BASE_SHA or CIRRUS_TAG are set + return 1 fi - echo "Found \$RELVER $RELVER" if [[ -n "$RELVER" ]]; then + echo "Found \$RELVER $RELVER" if echo "$RELVER" | grep -q '-'; then - return 2 + return 2 # development tag else return 0 fi else - return 1 + return 1 # not a release fi } |