Skip to content

Instantly share code, notes, and snippets.

@kanryu
Last active March 30, 2017 19:32
Show Gist options
  • Save kanryu/f4db8e0460310309063d2cf56379b3b3 to your computer and use it in GitHub Desktop.
Save kanryu/f4db8e0460310309063d2cf56379b3b3 to your computer and use it in GitHub Desktop.
minimalist auto generator for CHANGELOG.md (awk)
BEGIN {
print "# CHANGELOG"
COMMIT = ""
OTHER_COMMIT_FIRST=1
DATE = ""
TAG = ""
"git config --get remote.origin.url" | getline ORIGIN
}
/^commit/ {
COMMIT=$2
if($0 !~ /tag:/) {
TAG = ""
next
}
TAG=gensub(/.+tag\: (.+)\)$/, "\\1", "g", $0)
OTHER_COMMIT_FIRST=1
}
/^Date:/ {
DATE = substr($0, 9)
if(TAG != "") {
print ""
print "## " TAG " (" DATE ") [" substr(COMMIT, 0, 7) "](" ORIGIN "/commit/" COMMIT ")"
print ""
COMMIT = ""
}
}
/^ / {
if(TAG != "") {
sub(/^ +/, "") ; print
} else {
if(OTHER_COMMIT_FIRST) {
print ""
print "- other commits"
OTHER_COMMIT_FIRST=0
}
sub(/^ +-?/, "")
print " - " $0 " (" DATE ") [" substr(COMMIT, 0, 7) "](" ORIGIN "/commit/" COMMIT ")"
}
}
@kanryu
Copy link
Author

kanryu commented Mar 29, 2017

setup this script into some your favorite dir.

$ cat ~/.genchangelog/genchangelog.awk

and create alias

$ git config --global --add alias.changelog "!git log --decorate | awk -f $HOME/.genchangelog/genchangelog.awk"

so, you can generate CHANGELOG.md at local repository dir

$ git changelog > CHANGELOG.md

output example

https://github.com/kanryu/quickviewer/blob/master/CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment