summary refs log tree commit diff
path: root/pkgs/common-updater/scripts/list-git-tags
blob: ff09671c7cb0aa2a7aa6647ff60923b3a092cd4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /bin/sh -x

# 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"