Path: blob/main/Tools/scripts/git-get-latest-remote-version.sh
18878 views
#!/bin/sh1#2# MAINTAINER: [email protected]34set -e5set -o pipefail67export LC_ALL=C89##10## git-get-latest-remote-version.sh: retrieves the latest version of a given Git project on github.com11##1213# args1415REPOSITORY_URL="$1"16TAG_PREFIX="$2"1718if [ -z "$REPOSITORY_URL" ]; then19echo "Usage: $0 <repository-url> <tag-prefix>"20exit 121fi2223# check that packaged dependencies are installed2425for dep in git version_sort; do26if ! which -s $dep; then27echo "error: the '$dep' dependency is missing"28if [ $dep == "git" ]; then29echo "... please install the 'git' package"30elif [ $dep == "version_sort" ]; then31echo "... please install the 'libversion' package"32fi33exit 134fi35done363738# MAIN3940git ls-remote --refs --tags $REPOSITORY_URL 2>/dev/null |41grep "refs/tags/$TAG_PREFIX" |42sed -e "s|.*refs/tags/$TAG_PREFIX||" |43version_sort |44tail -1 ||45! echo "failed to find the git project or tags in it"464748