Skip to content

Instantly share code, notes, and snippets.

@killua99
Created May 7, 2014 21:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killua99/91bf34817bf0b2a94635 to your computer and use it in GitHub Desktop.
Save killua99/91bf34817bf0b2a94635 to your computer and use it in GitHub Desktop.
bash script to generate changelog focused for Drupal modules
#!/bin/bash
# Author: Luigi Guevara <@killua99>
#
# Use
# For a Simple Tag changelog
# ./changelog > CHANGELOG.txt
#
# For a current dev branch with the old tag log
# ./changelog 7.x-2.x > CHANGELOG.txt
MODULE_NAME=`grep -oP 'name\s*=\s*.*' *.info | grep -oP '[^name\s*=\s*].*'`
CURRENT_BRANCH=$1
echo "CHANGELOG: $MODULE_NAME"
echo -----------------------------
if [ $CURRENT_BRANCH ]; then
echo
echo "[$CURRENT_BRANCH xxxx-xx-xx] (Dev branch)"
echo
LOG=$(git log --no-merges --format=' - %w(75,0,3)%s' $CURRENT_BRANCH)
echo "$LOG"
fi
git for-each-ref --shell --sort='-authordate' --format="tag=%(refname:short) date=%(authordate:short)" refs/tags | \
while read ENTRY
do
eval $ENTRY
LOG=$(git log --no-merges --format=" - %w(75,0,3)%s" $tag)
echo
echo "[$tag - $date]"
echo
echo "$LOG"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment