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-09-27 20:49:23 +00:00
|
|
|
|
pname="" # package name
|
|
|
|
|
attr_path="" # package attribute path
|
2022-02-21 01:11:49 +00:00
|
|
|
|
url="" # git repository url
|
|
|
|
|
file="" # file for writing debugging information
|
|
|
|
|
|
|
|
|
|
while (( $# > 0 )); do
|
|
|
|
|
flag="$1"
|
|
|
|
|
shift 1
|
|
|
|
|
case "$flag" in
|
|
|
|
|
--pname=*)
|
|
|
|
|
pname="${flag#*=}"
|
|
|
|
|
;;
|
2022-09-27 20:49:23 +00:00
|
|
|
|
--attr-path=*)
|
|
|
|
|
attr_path="${flag#*=}"
|
|
|
|
|
;;
|
|
|
|
|
--url=*)
|
|
|
|
|
url="${flag#*=}"
|
|
|
|
|
;;
|
2022-02-21 01:11:49 +00:00
|
|
|
|
--file=*)
|
|
|
|
|
file="${flag#*=}"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "$0: unknown option ‘${flag}’"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2022-09-27 20:49:23 +00:00
|
|
|
|
if [[ -z "$pname" ]]; then
|
2022-09-30 13:04:43 +00:00
|
|
|
|
pname="$UPDATE_NIX_PNAME"
|
2022-09-27 20:49:23 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ -z "$attr_path" ]]; then
|
|
|
|
|
attr_path="$UPDATE_NIX_ATTR_PATH"
|
|
|
|
|
fi
|
|
|
|
|
|
2022-02-21 01:11:49 +00:00
|
|
|
|
# By default we set url to src.url or src.meta.homepage
|
|
|
|
|
if [[ -z "$url" ]]; then
|
|
|
|
|
url="$(nix-instantiate $systemArg --eval -E \
|
2022-09-27 20:49:23 +00:00
|
|
|
|
"with import ./. {}; $attr_path.src.meta.homepage or $attr_path.src.url" \
|
2022-02-21 01:11:49 +00:00
|
|
|
|
| tr -d '"')"
|
|
|
|
|
fi
|
2020-04-13 20:57:30 +00:00
|
|
|
|
|
|
|
|
|
# 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
|
2023-02-10 10:29:52 +00:00
|
|
|
|
tags=$(echo "$tags" | cut --delimiter=/ --field=3-)
|
2020-04-13 20:57:30 +00:00
|
|
|
|
|
|
|
|
|
echo "$tags"
|