Last active
April 13, 2018 10:32
-
-
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:
This file contains 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
#!/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