[git] Add git-changelog

This commit is contained in:
Matteo Cypriani 2012-11-03 19:15:55 +01:00
parent 7896c2ce60
commit 0abbb0bdfb
2 changed files with 91 additions and 0 deletions

View File

@ -1,3 +1,28 @@
# git-changelog #
git-changelog allows one to build a changelog file from the tag
messages. The tags considered are those whose names follow the format
vX.Y[.Z[...]] (for example v1.2, v0.0.1, v4.3.2.1, etc.).
One can edit the options into the script to change the message displayed
at the top of the changelog, and the number of line to separate two tag
messages.
The changelog is displayed on the standard output, in revese order
(higher version numbers first), whereas the error output displays the
included or skipped tag names (i.e. those which do not correspond to the
pattern).
Note that if there is no tag at all in the repository, no particular
warning will be displayed.
You can make this script a Git command by putting it in a directory
within your PATH (e.g. /usr/local/bin) and add an alias in your Git
configuration:
git config --global alias.changelog "\!sh -c 'git-changelog'"
# git-cherry-move #
git-cherry-move is like git cherry-pick, but it moves the commit

66
git/git-changelog Executable file
View File

@ -0,0 +1,66 @@
#!/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 | egrep '^v[0-9]+(\.[0-9]+)+$' >/dev/null ; 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=`expr $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