nixpkgs/pkgs/common-updater/scripts/list-git-tags
2021-10-01 18:42:18 +02:00

33 lines
738 B
Bash
Executable File

#!/usr/bin/env bash
# lists all available tags from a git repository
scriptName=list-git-tags # do not use the .wrapped name
usage() {
echo "Usage: $scriptName <repository url> [<package name> [<debug file path>]]"
}
repo="$1" # git repository url
pname="$2" # package name
file="$3" # file for writing debugging information
if [ -z "$repo" ]; then
echo "$scriptName: Missing git repository url"
usage
exit 1
fi
# print a debugging message
if [ -n "$file" ]; then
echo "# Listing tags for $pname at $repo" >> $file
fi
# list all tags from the remote repository
tags=$(git ls-remote --tags --refs "$repo")
# keep only the version part of the tag
tags=$(echo "$tags" | cut --delimiter=/ --field=3)
echo "$tags"