common.sh: osmo_git_last_commits_tags: add "all"

Allow printing all tags instead of only the N most recent ones.

Related: OS#3870
Change-Id: I684c6881915831b33b679e8ae873213beb034ab7
This commit is contained in:
Oliver Smith 2019-06-28 14:46:00 +02:00
parent e26866af0d
commit a5d5bedd55
1 changed files with 4 additions and 2 deletions

View File

@ -16,7 +16,7 @@ osmo_git_head_commit() {
# Print last tags and related commits for an Osmocom git repository, e.g.:
# "ec798b89700dcca5c5b28edf1a1cd16ea311f30a refs/tags/1.0.1"
# $1: Osmocom repository
# $2: amount of commit, tag pairs to print (default: 1)
# $2: amount of commit, tag pairs to print (default: 1, set to "all" to print all)
# $3: string to print when there are no tags (default: empty string)
osmo_git_last_commits_tags() {
# git output:
@ -31,7 +31,9 @@ osmo_git_last_commits_tags() {
ret="$(git ls-remote --tags "$OSMO_GIT_URL/$1")"
ret="$(echo "$ret" | grep 'refs/tags/[0-9.]*$' || true)"
ret="$(echo "$ret" | sort -V -t/ -k3)"
ret="$(echo "$ret" | tail -n "$2")"
if [ "$2" != "all" ]; then
ret="$(echo "$ret" | tail -n "$2")"
fi
if [ -n "$ret" ]; then
echo "$ret"