nixpkgs/pkgs/common-updater/scripts/list-git-tags

54 lines
1.2 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# lists all available tags from a git repository
echo "# pname=$UPDATE_NIX_ATTR_PATH" > /tmp/test.txt
url="" # git repository url
pname="" # package name
file="" # file for writing debugging information
while (( $# > 0 )); do
flag="$1"
shift 1
case "$flag" in
--url=*)
url="${flag#*=}"
;;
--pname=*)
pname="${flag#*=}"
;;
--file=*)
file="${flag#*=}"
;;
*)
echo "$0: unknown option ${flag}"
exit 1
;;
esac
done
# By default we set url to src.url or src.meta.homepage
if [[ -z "$url" ]]; then
url="$(nix-instantiate $systemArg --eval -E \
"with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.meta.homepage or $UPDATE_NIX_ATTR_PATH.src.url" \
| tr -d '"')"
fi
if [[ -z "$pname" ]]; then
pname="$UPDATE_NIX_ATTR_PATH"
fi
# print a debugging message
if [[ -n "$file" ]]; then
echo "# Listing tags for '$pname' at $url" >> $file
fi
# list all tags from the remote repository
tags=$(git ls-remote --tags --refs "$url")
# keep only the version part of the tag
tags=$(echo "$tags" | cut --delimiter=/ --field=3)
echo "$tags"