-
-
Save rondevera/a654b366f769fbf9cd56 to your computer and use it in GitHub Desktop.
Generates a Markdown changelog for a npm/bower repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function printCommitLine(){ | |
local FROM=$1 | |
local TO=$2 | |
if [ TO ]; then | |
git log $GIT_LOG_OPTS --format="$LOG_FORMAT_OPTS" $FROM..$TO | |
else | |
git log $GIT_LOG_OPTS --format="$LOG_FORMAT_OPTS" $FROM | |
fi | |
} | |
function printTitleLine(){ | |
local TAG=$1 | |
printf "\n" | |
echo "## [$TAG]($TAG_URL$TAG)" | |
} | |
if [ -e 'bower.json' ]; then | |
MANIFEST='./bower.json' | |
elif [ -e 'package.json' ]; then | |
MANIFEST='./package.json' | |
else | |
echo "Can't find package.json or bower.json" | |
exit 1 | |
fi | |
NAME=$(node -p "require('$MANIFEST').name") | |
TAG_URL="https://cgit.twitter.biz/$NAME/tag/?id=" | |
COMMIT_URL="https://cgit.twitter.biz/$NAME/commit/?id=%h" | |
GIT_LOG_OPTS="--no-merges" | |
LOG_FORMAT_OPTS=" * [%h]($COMMIT_URL) %s" | |
TAGS=$(git tag | grep '^\d\.\d\.\d' | sort -u -r) | |
PREV='HEAD' | |
FIRST=$(git rev-list --max-parents=0 HEAD) | |
for CTAG in ${TAGS[@]}; do | |
printTitleLine $PREV | |
printCommitLine $CTAG $PREV | |
PREV=$CTAG | |
done | |
printTitleLine $CTAG | |
printCommitLine $FIRST $CTAG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment