From da6765db4fd4f2762322c16b8a09efc733302e7c Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Sun, 9 Jan 2022 17:14:39 +0100 Subject: [PATCH] update_retroplayer-addons: improve tag resolution Make sure we always return the latest tag in the branch and only apply tag-suffix filtering if more than one tag exists. This ensures we won't pick up an older (eg -Nexus) tag if newer (eg -Matrix) tags are present - like it's currently the case with game addons which only get "-Matrix" tags. Signed-off-by: Matthias Reichl --- tools/mkpkg/update_common_functions | 22 ++++++++++++++-------- tools/mkpkg/update_retroplayer-addons | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/mkpkg/update_common_functions b/tools/mkpkg/update_common_functions index 7ae5a7d499..220ed3af21 100644 --- a/tools/mkpkg/update_common_functions +++ b/tools/mkpkg/update_common_functions @@ -67,17 +67,23 @@ resolve_hash_on_gh() { } resolve_tag_in_branch() { - local tag + local tag tags if [ -d "$1" ] ; then cd "$1" - if [ $# -eq 3 ] ; then - tag=$(git describe --abbrev=0 --tags --match "$3" origin/$2 2>/dev/null) - if [ -n "$tag" ] ; then - echo "$tag" - return - fi + tag=$(git describe --abbrev=0 --tags origin/$2 2>/dev/null) + if [ -z "${tag}" ]; then + return fi - git describe --abbrev=0 --tags origin/$2 2>/dev/null + tags=( $(git tag --points-at "${tag}" | sort -r -n) ) + if [ $# -eq 3 -a ${#tags[@]} -gt 1 ]; then + for tag in "${tags[@]}"; do + if [[ "${tag}" =~ $3 ]]; then + echo "$tag" + return + fi + done + fi + echo "${tags[0]}" fi } diff --git a/tools/mkpkg/update_retroplayer-addons b/tools/mkpkg/update_retroplayer-addons index a425f1ab0a..b758e4e253 100755 --- a/tools/mkpkg/update_retroplayer-addons +++ b/tools/mkpkg/update_retroplayer-addons @@ -132,7 +132,7 @@ for addon in ${ADDONS_DIR}/*.*/ ; do if [ -z "$GITHUB_API_TOKEN" ]; then git_clone "${GAME_GIT_REPO}" "${GAME_GIT_DIR}" if [ -n "${TAG_SUFFIX}" ]; then - GAME_NEW_VERSION=$(resolve_tag_in_branch "${GAME_GIT_DIR}" "${GAME_GIT_BRANCH}" "*-${TAG_SUFFIX}") + GAME_NEW_VERSION=$(resolve_tag_in_branch "${GAME_GIT_DIR}" "${GAME_GIT_BRANCH}" ".*-${TAG_SUFFIX}$") else GAME_NEW_VERSION=$(resolve_tag_in_branch "${GAME_GIT_DIR}" "${GAME_GIT_BRANCH}") fi