From 5e257d407b4abf2be61c656dfb1d383396df35b1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 3 Jan 2017 23:02:19 -0500 Subject: ChangeLog --- Makefile | 2 +- TODO.org | 1 - bin/auto-changelog | 46 ++++++++++++++++++++++++++++++++++++++++++++++ bin/page.html.erb | 2 +- bin/post-commit | 38 -------------------------------------- bin/post-commit.githook | 6 ++++++ bin/pre-generate | 34 ++++++++++++++++++++++++++++++++++ git-setup | 2 +- src/ChangeLog.md | 16 ++++++++++++++++ 9 files changed, 105 insertions(+), 42 deletions(-) create mode 100755 bin/auto-changelog delete mode 100755 bin/post-commit create mode 100755 bin/post-commit.githook create mode 100755 bin/pre-generate create mode 100644 src/ChangeLog.md diff --git a/Makefile b/Makefile index be186c8..dc232dd 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ out/%.css: src/%.scss out/%.css: out/%.scss scss --stdin < $< > $@ -index.all = $(html.src) $(shell find src -type f -name index.yaml) +index.all = $(filter-out %/ChangeLog.md %/index.md,$(html.src) $(shell find src -type f -name index.yaml)) index.filter = $(filter-out %/index.yaml,$(filter $(@D)/% $(patsubst out%,src%,$(@D))/%,$1)) index.cmd = bin/index $(patsubst .%,%,$(suffix $@)) $(@D) $(call index.filter,$^) | bin/write-atomic $@ index.dep = $(bin/index) bin/index.$1.erb .var.index.all $(index.all) bin/write-atomic Makefile diff --git a/TODO.org b/TODO.org index 90da080..647e96e 100644 --- a/TODO.org +++ b/TODO.org @@ -1,6 +1,5 @@ * functionality - tag filtering -- changelog (blog) - categories (writing/programming/dnd) * style - org tables diff --git a/bin/auto-changelog b/bin/auto-changelog new file mode 100755 index 0000000..dcf33a2 --- /dev/null +++ b/bin/auto-changelog @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -e + +list-files() { + git show --pretty="" --name-only HEAD +} + +list-articles() { + list-files | grep -E '^src/.*[.](md|org)$' | grep -v -e '/index[.]md$' -e '/ChangeLog[.]md$' +} + +should-insert() { + test -n "$(list-articles)" +} + +generate-entry() { + git log -n1 --stat --date='format:%Y-%m-%d' --format=$'## %ad %an <%ae>\n\n%B' | cat -s +} + +html_escape() { + sed -e 's/&/\&/g' -e 's//\>/g' -e 's/^ \S/ &/' +} + +insert() { + { + printf '%s\n' \ + 'ChangeLog' \ + '=========' \ + '' + + generate-entry | html_escape + echo + cat src/ChangeLog.md | sed '1,3d' + } | bin/write-atomic src/ChangeLog.md +} + +main() { + cd "$(dirname -- "$0")/.." + if should-insert; then + insert + git add src/ChangeLog.md + git commit -m 'Auto-insert entry to ChangeLog' + fi +} + +main "$@" diff --git a/bin/page.html.erb b/bin/page.html.erb index 1171705..4ee5473 100644 --- a/bin/page.html.erb +++ b/bin/page.html.erb @@ -13,7 +13,7 @@