2021-09-29 14:41:19 +00:00
|
|
|
|
#!/usr/bin/env bash
|
2020-04-13 20:57:30 +00:00
|
|
|
|
|
|
|
|
|
# lists all available tags from a git repository
|
|
|
|
|
|
2022-02-21 01:11:49 +00:00
|
|
|
|
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 \
|
2022-04-23 18:35:52 +00:00
|
|
|
|
"with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.meta.homepage or $UPDATE_NIX_ATTR_PATH.src.url" \
|
2022-02-21 01:11:49 +00:00
|
|
|
|
| tr -d '"')"
|
|
|
|
|
fi
|
2020-04-13 20:57:30 +00:00
|
|
|
|
|
2022-02-21 01:11:49 +00:00
|
|
|
|
if [[ -z "$pname" ]]; then
|
|
|
|
|
pname="$UPDATE_NIX_ATTR_PATH"
|
2020-04-13 20:57:30 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# print a debugging message
|
2022-02-21 01:11:49 +00:00
|
|
|
|
if [[ -n "$file" ]]; then
|
|
|
|
|
echo "# Listing tags for '$pname' at $url" >> $file
|
2020-04-13 20:57:30 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# list all tags from the remote repository
|
2022-02-21 01:11:49 +00:00
|
|
|
|
tags=$(git ls-remote --tags --refs "$url")
|
2020-04-13 20:57:30 +00:00
|
|
|
|
|
|
|
|
|
# keep only the version part of the tag
|
|
|
|
|
tags=$(echo "$tags" | cut --delimiter=/ --field=3)
|
|
|
|
|
|
|
|
|
|
echo "$tags"
|