aboutsummaryrefslogtreecommitdiffstats
path: root/git-which-tag.sh
blob: b5d73901eefabe0e379557cd8d30efac2b5aa808 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh
set -eu

[ "$#" -lt 1 ] && exit 1

git log --color=never --all --pretty='%h' --grep="${1}" | while read -r ID ; do
    tags="$(git tag --no-column -l 'v*' --sort='version:refname' --contains "$ID" \
        | head -n 5 | tr '\n' ' ')"
    if [ -n "$tags" ] ; then
        printf "%s: %s\n" "$ID" "$tags"
    fi
done