Skip to content

Commit

Permalink
fix: added different branches checking
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsonbrsilva committed May 13, 2024
1 parent 0ce8207 commit cecca8e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions actions/latest-version-obtaining/latest-version-obtaining.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ is_version_published() {
[[ -n "${result}" ]]
}

is_different() {
[[ "${1}" != "${2}" ]]
}

get_newest_version_between() {
printf "%s\n%s\n" "${1}" "${2}" | sort --version-sort | tail --lines 1
}
Expand Down Expand Up @@ -57,13 +61,17 @@ get_last_version() {
local version=$(get_newest_version_between "${last_origin_branch_version}" "${last_repository_version}")

if is_version_published "${last_origin_branch_version}" "${main_branch}"; then
version="${last_origin_branch_version}"
printf "The origin branch version is in '%s'.\n" "${main_branch}"
if is_different "${origin_branch}" "${main_branch}"; then
version="${last_origin_branch_version}"
printf "The origin branch version is in '%s'.\n" "${main_branch}"
fi
fi

if is_version_published "${last_repository_version}" "${main_branch}"; then
version="${last_repository_version}"
printf "The repository version is in '%s'.\n" "${main_branch}"
if is_different "${origin_branch}" "${main_branch}"; then
version="${last_repository_version}"
printf "The repository version is in '%s'.\n" "${main_branch}"
fi
fi

if is_missing "${version}"; then
Expand Down

0 comments on commit cecca8e

Please sign in to comment.