Skip to content

Instantly share code, notes, and snippets.

@bweir
Last active August 3, 2016 06:01
Show Gist options
  • Save bweir/cd8e0b9483d7df9ef780759d473ca469 to your computer and use it in GitHub Desktop.
Save bweir/cd8e0b9483d7df9ef780759d473ca469 to your computer and use it in GitHub Desktop.
Fancy Markdown Git Changelog in 25 lines or less
#!/bin/bash
OUT="changelog.md"
echo "$(basename $(git rev-parse --show-toplevel)) Changelog" > $OUT
echo "----------------------" >> $OUT
echo >> $OUT
git log --format=format:" - %d %s" \
| sed -e '/Merge /d' \
-e '/Update/d' -e '/update/d' \
-e '/README/d' -e '/readme/d' \
-e '/AUTHORS/d' -e '/COPYING/d' -e '/LICENSE/d' \
-e '/authors/d' -e '/copying/d' -e '/license/d' \
-e '/WIP/d' \
-e '/ci skip/d' \
-e '/skip ci/d' \
| sed -e 's/[ \t]*-[ \t]*(tag: \([^)]\+\)) \(.*\)/\n**v\1**\n\n - \2/g' \
| sed -e 's/[ \t]*-[ \t]*([^)]\+, tag: \([^)]\+\), [^)]\+, [^)]\+) \(.*\)/**v\1**\n\n - \2/g' \
| fold -s \
| sed -e '/^\( -\|\*\*\)/!s/^/ /' \
| sed -e 's/\[.*\]/`&` /g' \
| sed -e 's/[a-zA-Z0-9_]\+([a-zA-Z0-9, ]*)/`&`/g' \
| sed -e 's/[a-zA-Z]\+_[a-zA-Z0-9_]*/`&`/g' \
>> $OUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment