tridactyl/scripts/when_feature.sh

26 lines
752 B
Bash
Raw Permalink Normal View History

2023-11-19 14:00:55 +01:00
#!/bin/bash
# find earliest possible beta release tag for a given feature
# usage: ./when_feature.sh "text that appears in log"
# create array of commits that contain the line
commits=$(git log -S "$@" --oneline --all --reverse | cut -d ' ' -f 1)
# loop through commits until we find one that has a tag
for commit in $commits
do
# get the tag for the commit
2023-12-12 19:32:07 +01:00
tag=$(git describe --tags "$commit" 2> /dev/null)
2023-11-19 14:00:55 +01:00
# if the commit has a tag, break out of the loop
if [ -n "$tag" ]
then
break
fi
done
2023-12-12 19:32:07 +01:00
prestr=pre$(git rev-list --count "$commit")
2023-11-19 14:00:55 +01:00
# replace the middle number in tag-number-commit with prestr
# nb: there's an extra -g but I don't care enough
2023-12-12 19:32:07 +01:00
echo "$tag" | sed "s/\([^-]*\)-\([^-]*\)-\([^-]*\)/\1-$prestr-\3/"