Created
March 31, 2016 09:29
-
-
Save T0aD/814bd6a15075dd4007a7b03be73a6408 to your computer and use it in GitHub Desktop.
Generate changlog from last 2 tags of a gGIT repository
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 | |
git pull --all # fetch last changes from all branches | |
git pull --tags # fetch all tags | |
# switch to prod: | |
git checkout prod | |
#git tag # display tags | |
# generate changelog: | |
#git log 0.4.9.1...0.4.10 --pretty=format:"%ad: %s" --date=short | |
# get all tags sorted: | |
#git for-each-ref --sort=taggerdate --format '%(refname) %(taggerdate)' refs/tags | |
#git for-each-ref --sort=-taggerdate --format '%(refname) %(taggerdate)' --count=2 refs/tags | |
# get last tag and date: | |
echo "# Changelog" | |
echo -n "## Release: " | |
git for-each-ref --sort=-taggerdate --format '%(refname) %(taggerdate)' --count=1 refs/tags | |
last_tag=`git for-each-ref --sort=-taggerdate --format '%(refname) %(taggerdate)' --count=1 refs/tags | awk '{print $1}' | sed 's/refs\/tags\///'` | |
#echo $last_tag | |
previous_tag=`git for-each-ref --sort=-taggerdate --format '%(refname) %(taggerdate)' --count=2 refs/tags | tail -1 | awk '{print $1}' | sed 's/refs\/tags\///'` | |
#echo $previous_tag | |
echo "Generating changelog from $previous_tag to $last_tag:" | |
git log $previous_tag...$last_tag --pretty=format:"%ad: %s" --date=short |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment