scripts/git/git-changelog

67 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

2012-11-03 19:15:55 +01:00
#!/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
2018-04-11 23:28:36 +02:00
if echo "$TAG" | grep -Eq '^v[0-9]+(\.[0-9]+)+$' ; then
2012-11-03 19:15:55 +01:00
# Display current tag's name
2018-04-11 23:28:36 +02:00
echo "$TAG" >&2
2012-11-03 19:15:55 +01:00
# Print empty lines if needed
if [ $PRINTNL -eq 1 ] ; then
i=0
while [ $i -lt $NEWLINES ] ; do
echo
2018-04-11 23:28:36 +02:00
i=$((i + 1))
2012-11-03 19:15:55 +01:00
done
fi
# Print the tag message
2018-04-11 23:28:36 +02:00
git tag -l "$TAG" -n$NBLINES | sed 's/ \+$//'
2012-11-03 19:15:55 +01:00
PRINTNL=1
else
echo "Skipping $TAG" >&2
fi
done