diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-03 23:02:19 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-03 23:02:19 -0500 |
commit | 5e257d407b4abf2be61c656dfb1d383396df35b1 (patch) | |
tree | 7d8914d78aeb741c7d0ae787eb4acbcce93f5f38 /bin | |
parent | ba05c5fb2ccf4b5e90c97adc17e784a77248d9f1 (diff) |
ChangeLog
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/auto-changelog | 46 | ||||
-rw-r--r-- | bin/page.html.erb | 2 | ||||
-rwxr-xr-x | bin/post-commit | 38 | ||||
-rwxr-xr-x | bin/post-commit.githook | 6 | ||||
-rwxr-xr-x | bin/pre-generate | 34 |
5 files changed, 87 insertions, 39 deletions
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/>/\>/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 @@ <nav> <ul> <li><a href="/">Projects</a> - <li><a href="/blahg/CHANGELOG.html"><abbr title="Blog">Blahg</abbr></a> + <li><a href="/ChangeLog.html"><abbr title="Blog">Blahg</abbr></a> <li><a href="/Andrew.html">Andrew</a> <li> <form method="GET" action="/search.html"> diff --git a/bin/post-commit b/bin/post-commit deleted file mode 100755 index 489181f..0000000 --- a/bin/post-commit +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2016-2017 Luke Shumaker -set -e - -main() { - branch=$(git name-rev --name-only HEAD) - if [[ $branch == master ]]; then - gitdir="$(git rev-parse --git-dir)" - workdir="${gitdir}/pre-generated" - exec 8>"${workdir}.lock" - flock 8 - - rm -rf -- "$workdir" - git worktree prune - git branch -D pre-generated.tmp &>/dev/null || true - - git worktree add -b pre-generated.tmp "${gitdir}/pre-generated" master - ( - unset GIT_DIR GIT_WORK_TREE - cd "$workdir" - msg="$(git log -n1 master --pretty=format:%B)" - - make -j1 - echo '!/out/' >> .gitignore - - git add . - git commit -m "make: $msg" - git merge --no-edit -s ours pre-generated - git checkout pre-generated - git merge pre-generated.tmp - git branch -d pre-generated.tmp - ) - rm -rf -- "$workdir" - git worktree prune - fi -} - -main &>/dev/tty & diff --git a/bin/post-commit.githook b/bin/post-commit.githook new file mode 100755 index 0000000..3f576e6 --- /dev/null +++ b/bin/post-commit.githook @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -e +d="$(dirname -- "$0")" + +"$d"/auto-changelog +"$d"/pre-generate &>/dev/tty & diff --git a/bin/pre-generate b/bin/pre-generate new file mode 100755 index 0000000..bd1c21e --- /dev/null +++ b/bin/pre-generate @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Copyright 2016-2017 Luke Shumaker +set -e + +branch=$(git name-rev --name-only HEAD) +if [[ $branch == master ]]; then + gitdir="$(git rev-parse --git-dir)" + workdir="${gitdir}/pre-generated" + exec 8>"${workdir}.lock" + flock 8 + + rm -rf -- "$workdir" + git worktree prune + git branch -D pre-generated.tmp &>/dev/null || true + + git worktree add -b pre-generated.tmp "${gitdir}/pre-generated" master + ( + unset GIT_DIR GIT_WORK_TREE + cd "$workdir" + msg="$(git log -n1 master --pretty=format:%B)" + + make -j1 + echo '!/out/' >> .gitignore + + git add . + git commit -m "make: $msg" + git merge --no-edit -s ours pre-generated + git checkout pre-generated + git merge pre-generated.tmp + git branch -d pre-generated.tmp + ) + rm -rf -- "$workdir" + git worktree prune +fi |