Date: Sat, 27 Sep 2025 16:33:19 GMT From: Yuri Victorovich <yuri@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: c152034fe0e2 - main - Tools/scripts: Add git-get-latest-remote-version.sh Message-ID: <202509271633.58RGXJ1H033278@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=c152034fe0e2a3dd5dc673a6cc479bf2536a11ab commit c152034fe0e2a3dd5dc673a6cc479bf2536a11ab Author: Yuri Victorovich <yuri@FreeBSD.org> AuthorDate: 2025-09-27 16:18:29 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2025-09-27 16:33:13 +0000 Tools/scripts: Add git-get-latest-remote-version.sh Script to quickly find the last tag in a git URL with a given prefix. --- Tools/scripts/git-get-latest-remote-version.sh | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Tools/scripts/git-get-latest-remote-version.sh b/Tools/scripts/git-get-latest-remote-version.sh new file mode 100755 index 000000000000..452874881b7d --- /dev/null +++ b/Tools/scripts/git-get-latest-remote-version.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# +# MAINTAINER: yuri@FreeBSD.org + +set -e +set -o pipefail + +export LC_ALL=C + +## +## git-get-latest-remote-version.sh: retrieves the latest version of a given Git project on github.com +## + +# args + +REPOSITORY_URL="$1" +TAG_PREFIX="$2" + +if [ -z "$REPOSITORY_URL" ]; then + echo "Usage: $0 <repository-url> <tag-prefix>" + exit 1 +fi + +# check that packaged dependencies are installed + +for dep in git version_sort; do + if ! which -s $dep; then + echo "error: the '$dep' dependency is missing" + if [ $dep == "git" ]; then + echo "... please install the 'git' package" + elif [ $dep == "version_sort" ]; then + echo "... please install the 'libversion' package" + fi + exit 1 + fi +done + + +# MAIN + +git ls-remote --refs --tags $REPOSITORY_URL 2>/dev/null | + grep "refs/tags/$TAG_PREFIX" | + sed -e "s|.*refs/tags/$TAG_PREFIX||" | + version_sort | + tail -1 || + ! echo "failed to find the git project or tags in it"home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509271633.58RGXJ1H033278>
