aboutsummaryrefslogtreecommitdiffstats
path: root/git-which-tag.sh
blob: 0ccb719dba057b6cf961860c33a8dec6b3861e0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/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' ' ')"
    subject="$(git  rev-list --max-count=1 --no-commit-header --format=%s "$ID")"
    if [ -n "$tags" ] ; then
        printf "%s: %s %s\n" "$ID" "$tags" "$subject"
    fi
done