Flexible Lisp Blogware. Fork for personal use. Mirrored from https://github.com/kingcons/coleslaw originally.

git.lisp 876B

12345678910111213141516171819202122232425
  1. (in-package :coleslaw)
  2. (defun last-commit ()
  3. "Retrieve the SHA1 hash of the most recent blog commit."
  4. (multiple-value-bind (pid stdout stderr)
  5. (with-current-directory (repo *config*)
  6. (run-program "git" '("log" "-n 1")))
  7. (cl-ppcre:scan-to-strings "[0-9a-f]{40}" stdout)))
  8. (defun last-published ()
  9. "Retrieve the SHA1 hash of the most recent published blog."
  10. (with-open-file (in "/home/redline/.coleslaw" :if-does-not-exist :create)
  11. (read-line in nil)))
  12. (defun (setf last-published) (new-val)
  13. (with-open-file (out "/home/redline/.coleslaw"
  14. :direction :output
  15. :if-exists :supersede
  16. :if-does-not-exist :create)
  17. (write-line new-val out)))
  18. (defun blog-update-p ()
  19. "Returns a non-nil value if the blog needs to be regenerated."
  20. (mismatch (last-commit) (last-published)))