aboutsummaryrefslogtreecommitdiffstats
path: root/git-which-tag.sh
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-04-11 11:05:22 +0200
committerMatěj Cepl <mcepl@cepl.eu>2024-10-07 11:02:09 +0200
commit802fa566c76a4ab2a66765c25db8fa9968e3e2c0 (patch)
tree3325564b56ae20a08548b841f7ae15a61240b102 /git-which-tag.sh
parent02a8a8f74ff759bac641f38df5ad26307c7ba87d (diff)
downloadgosc-802fa566c76a4ab2a66765c25db8fa9968e3e2c0.tar.gz
feat(git-which-tag): list tags containing commits identified by grep string
Diffstat (limited to 'git-which-tag.sh')
-rwxr-xr-xgit-which-tag.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/git-which-tag.sh b/git-which-tag.sh
new file mode 100755
index 0000000..b2665f5
--- /dev/null
+++ b/git-which-tag.sh
@@ -0,0 +1,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)"
+ if [ -n "$tags" ] ; then
+ printf "%s: %s\n" "$ID" "$tags"
+ fi
+done