diff options
author | Samruddhi Khandale <skhandale@microsoft.com> | 2022-12-01 00:42:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-01 00:42:57 +0300 |
commit | 46dfa11ecd3c507187eebbd6784c09d736737255 (patch) | |
tree | 41343cae844ba4dcea3461d908ab157a2e3ea733 /src/nix/utils.sh | |
parent | 64f0e10fab232f132c566f5c70d419f3106c381b (diff) |
Github cli - Adds retry logic for find git tags (#310)
* Github cli - Adds retry logic for find git tags
* re-add set -e
* address comment
Diffstat (limited to 'src/nix/utils.sh')
-rwxr-xr-x | src/nix/utils.sh | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nix/utils.sh b/src/nix/utils.sh index 68cdd9d..5753e5a 100755 --- a/src/nix/utils.sh +++ b/src/nix/utils.sh @@ -282,14 +282,19 @@ find_prev_version_from_git_tags() { major="$(echo "${current_version}" | grep -oE '^[0-9]+' || echo '')" minor="$(echo "${current_version}" | grep -oP '^[0-9]+\.\K[0-9]+' || echo '')" breakfix="$(echo "${current_version}" | grep -oP '^[0-9]+\.[0-9]+\.\K[0-9]+' 2>/dev/null || echo '')" - set -e + + if [ "${minor}" = "0" ] && [ "${breakfix}" = "0" ]; then + ((major=major-1)) + declare -g ${variable_name}="${major}" + # Look for latest version from previous major release + find_version_from_git_tags "${variable_name}" "${repository}" "${prefix}" "${separator}" "${last_part_optional}" # Handle situations like Go's odd version pattern where "0" releases omit the last part - if [ "${breakfix}" = "" ] || [ "${breakfix}" = "0" ]; then + elif [ "${breakfix}" = "" ] || [ "${breakfix}" = "0" ]; then ((minor=minor-1)) declare -g ${variable_name}="${major}.${minor}" # Look for latest version from previous minor release find_version_from_git_tags "${variable_name}" "${repository}" "${prefix}" "${separator}" "${last_part_optional}" - else + else ((breakfix=breakfix-1)) if [ "${breakfix}" = "0" ] && [ "${last_part_optional}" = "true" ]; then declare -g ${variable_name}="${major}.${minor}" @@ -297,4 +302,6 @@ find_prev_version_from_git_tags() { declare -g ${variable_name}="${major}.${minor}.${breakfix}" fi fi + + set -e }
\ No newline at end of file |