From 3088b6de8e1ab975cd077bf176984c56f2b336f7 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Sat, 3 May 2014 17:23:34 -0400 Subject: [PATCH] Add *updated-files* to track files changed in the last push. --- coleslaw.asd | 2 +- docs/hacking.md | 15 --------------- examples/example.post-receive | 22 +++++++++++++--------- src/coleslaw.lisp | 10 ++++++++-- src/packages.lisp | 1 + 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/coleslaw.asd b/coleslaw.asd index c0daab3..f7f4ab2 100644 --- a/coleslaw.asd +++ b/coleslaw.asd @@ -1,7 +1,7 @@ (defsystem #:coleslaw :name "coleslaw" :description "Flexible Lisp Blogware" - :version "0.9.4-dev" + :version "0.9.4" :license "BSD" :author "Brit Butler " :pathname "src/" diff --git a/docs/hacking.md b/docs/hacking.md index 5adee29..0960a4a 100644 --- a/docs/hacking.md +++ b/docs/hacking.md @@ -240,20 +240,6 @@ avoiding work is better than using more workers. Moreover, being able to determine (and expose) what files just changed enables new functionality such as plugins that cross-post to tumblr. -Git's post-receive hook is supposed to get a list of refs on $STDIN. -A brave soul could update our post-receive script to iterate over -those lines as shown in step 3 of this [blog post][post_receive_blog]. -There would be two primary benefits: - -1. We could pass the oldrev (previous revision) of the blog repo - to `coleslaw:main`. That could be used in conjunction with - `get-updated-files` to get a list of the files modified in the - last push. This would enable cross-posting plugins to be developed - as well as opening the door for incremental compilation. -2. More seriously, **Coleslaw** currently deploys for _any_ branch - pushed to the bare repo. This change would also ensure that we only - invoke `coleslaw:main` when a push is made to the master branch. - This is a cool project and the effects are far reaching. Among other things the existing deployment model would not work as it involves rebuilding the entire site. In all likelihood we would want to update @@ -264,7 +250,6 @@ would have to be regenerated along with any tag or month indexes matching the modified files. If incremental compilation is a goal, simply disabling the indexes may be appropriate for certain users. -[post_receive_blog]: http://codeshal.tumblr.com/post/927943180/git-post-receive-hook-that-submits-code-to-review-board [post_receive_hook]: https://github.com/redline6561/coleslaw/blob/master/examples/example.post-receive [closure_template]: https://github.com/archimag/cl-closure-template [api_docs]: https://github.com/redline6561/coleslaw/blob/master/docs/plugin-api.md diff --git a/examples/example.post-receive b/examples/example.post-receive index 78fd288..62670fc 100644 --- a/examples/example.post-receive +++ b/examples/example.post-receive @@ -20,15 +20,19 @@ fi git clone $GIT_REPO $TMP_GIT_CLONE || exit 1 -if [ $LISP = sbcl ]; then - sbcl --eval "(ql:quickload 'coleslaw)" \ - --eval "(coleslaw:main \"$TMP_GIT_CLONE\")" \ - --eval "(coleslaw::exit)" -elif [ $LISP = ccl ]; then - echo "(ql:quickload 'coleslaw)(coleslaw:main \"$TMP_GIT_CLONE\")(coleslaw::exit)" | ccl -b -else - exit 1 -fi +while read oldrev newrev refname; do + if [ $refname = "refs/head/master" ]; then + if [ $LISP = sbcl ]; then + sbcl --eval "(ql:quickload 'coleslaw)" \ + --eval "(coleslaw:main \"$TMP_GIT_CLONE\" \"$oldrev\")" \ + --eval "(coleslaw::exit)" + elif [ $LISP = ccl ]; then + ccl -e "(ql:quickload 'coleslaw) (coleslaw:main \"$TMP_GIT_CLONE\" \"$oldrev\") (coleslaw::exit)" + else + exit 1 + fi + fi +done rm -rf $TMP_GIT_CLONE exit diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index b147f31..12b1bd0 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -1,7 +1,13 @@ (in-package :coleslaw) -(defun main (&optional (repo-dir "")) - "Load the user's config file, then compile and deploy the site." +(defvar *updated-files* nil + "A plist of (file-status file-name) for files changed on the last git push.") + +(defun main (&optional (repo-dir "") oldrev) + "Load the user's config file, then compile and deploy the site. Optionally, +REPO-DIR is the location of the blog repo and OLDREV is the revision prior to +the last push." + (setf *updated-files* oldrev) (load-config repo-dir) (load-content) (compile-theme (theme *config*)) diff --git a/src/packages.lisp b/src/packages.lisp index 5061e50..0f8aa03 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -11,6 +11,7 @@ (:export #:main #:preview #:*config* + #:*updated-files* #:content #:post #:index