Skip to content

Instantly share code, notes, and snippets.

@AndrewFeeney
Last active April 13, 2018 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewFeeney/5be81727240e0c75e108f8e81ee78a2d to your computer and use it in GitHub Desktop.
Save AndrewFeeney/5be81727240e0c75e108f8e81ee78a2d to your computer and use it in GitHub Desktop.
A bash script to pre-populate a tag annotation in vim with the first line of all commits since last tag:
#!/bin/bash
# Tag the current commit with an annotation generated from the first line of the commit messages of all
# commits since the last tag. Default tag annotation is loaded into vim buffer and can be edited.
# Once you are happy with the message write the buffer and quit vim (type ":wq") and the tag will be generated
#
# Usage:
#
# tag 1.2.3
COMMITS_SINCE_LAST_TAG=$(git log `git describe --tags --abbrev=0`..HEAD --oneline)
echo "# Version $1"$'\n\n'Changelog:$'\n\n'"$COMMITS_SINCE_LAST_TAG" | vim - +'file TAG_ANNOTATION'
if [ -f TAG_ANNOTATION ]; then
git tag $1 --file=TAG_ANNOTATION
rm TAG_ANNOTATION
echo "Commit successfully tagged $1 with given annotation"
else
echo "Aborted. Tag not added."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment