Created
November 22, 2016 19:48
-
-
Save coleturner/6972590f7c7b4eaf2d2c7cfbd16ec883 to your computer and use it in GitHub Desktop.
SImple git tag shim for tracking per-day tags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DATE=`date +%Y%m%d` | |
NAME=$1 | |
if [[ -z $NAME ]]; then | |
read -p "Enter a tag group name [demo]: " NAME | |
fi | |
NAME=${NAME:-demo} | |
echo "Tags for $NAME-$DATE" | |
IN=$(git tag | grep "$NAME-$DATE") | |
TAGS=$(echo $IN | tr "\n" "\n") | |
MAX=1 | |
for TAG in $TAGS | |
do | |
echo "> $TAG" | |
INDEX=$(expr ${TAG##*-} + 0) | |
if (( $INDEX > $MAX )); then MAX=$INDEX; fi; | |
done | |
MAX=$((MAX+1)) | |
INDEX=$(printf %02d $MAX) | |
TAGNAME="$NAME-$DATE-$INDEX" | |
echo "Creating tag $TAGNAME" | |
git tag $TAGNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment