#!/bin/sh # # git-changelog, Copyright © 2012 Matteo Cypriani # # This program is free software. It comes without any warranty, to # the extent permitted by applicable law. You can redistribute it # and/or modify it under the terms of the Do What The Fuck You Want # To Public License, Version 2, as published by Sam Hocevar. See # http://sam.zoy.org/wtfpl/COPYING for more details. # # This script generates a changelog list from the Git tag messages. # Only the tags named after the format vX.Y[.Z[...]] are selected. # The changelog content is displayed on the standard output, whereas the # error output displays the included or skipped tag names. set -e #set -x ### User options # Message to display at the top of the file (blank to display nothing) HEADER="This file is automatically generated from the Git tag messages." # Number of blank lines between two tag messages NEWLINES=2 # Maximal number of lines to display for each tag message NBLINES=1000 ### End of user options if [ $# -ne 0 ] ; then echo "Warning! $0 takes no arguments!" >&2 fi # Indicates wether or not new lines should be printed PRINTNL=0 # Print the header if [ "$HEADER" != "" ] ; then echo "$HEADER" PRINTNL=1 fi for TAG in $(git tag -l | sort -r) ; do if echo "$TAG" | grep -Eq '^v[0-9]+(\.[0-9]+)+$' ; then # Display current tag's name echo "$TAG" >&2 # Print empty lines if needed if [ $PRINTNL -eq 1 ] ; then i=0 while [ $i -lt $NEWLINES ] ; do echo i=$((i + 1)) done fi # Print the tag message git tag -l "$TAG" -n$NBLINES | sed 's/ \+$//' PRINTNL=1 else echo "Skipping $TAG" >&2 fi done