Skip to content

Instantly share code, notes, and snippets.

@icyleaf
Created July 24, 2011 05:05
Show Gist options
  • Save icyleaf/1102269 to your computer and use it in GitHub Desktop.
Save icyleaf/1102269 to your computer and use it in GitHub Desktop.
Convert git-log to changlog day by day
#!/bin/bash
# Generates changelog day by day
#
# Defaults
#
VERSION="0.1"
AUTHOR="icyleaf <[email protected]>"
#
# Variables
#
GIT_AUTHOR=""
GIT_ONLY_TODAY=0
#
# Functions
#
usage() {
echo "Usage: changlog [<options>]"
echo "See 'changlog --help'."
exit 0
}
usage_long() {
less << EOF
USAGE
changlog [<options>]
DESCRIPTION
Convert git log to changlog.
OPTIONS
If no options is specified, the changlog will render all changlog from day by day.
OPTIONS
-h, --help Show this help
-a, --author Limit the commits output to ones with author/committer header lines that match the specified pattern
-t, --today Only render today changlog
--version Print current changlog version
EXAMPLES
. changloa -a lcyleaf
. kohana -a icyleaf -t
VERSION
$VERSION
AUTHOR
$AUTHOR
EOF
exit 0
}
changlog() {
if [ ! -z $GIT_AUTHOR]; then
$GIT_AUTHOR=" --author=$GIT_AUTHOR";
fi
if test -d ".git"; then
NEXT=$(date +%F)
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo
echo [$DATE]
GIT_PAGER=cat git log --no-merges --format=" * %s" $GIT_AUTHOR --since=$DATE --until=$NEXT
NEXT=$DATE
done
else
echo "No git repository present."
fi
}
# Parse parameters
while test $# != 0; do
case "$1" in
-h|--help)
usage_long
;;
-a|--author*)
INSTALL_SKELETON=1
;;
-t|--today)
INSTALL_SKELETON=0
;;
--version)
echo "changlog version $VERSION"
exit 0
;;
*)
usage
esac
shift
done
changlog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment