Yu-Gi-Oh! Deck Building and Card Inventory Management web interface written in Common Lisp, utilizing HTMX.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

71 satır
2.1KB

  1. #|
  2. src/toolkit/git.lisp
  3. Tools For Working with git repository information
  4. e.g. commit id, commit author, message, date, etc.
  5. TODO Use INFERIOR-SHELL? Turns out it just calls UIOP:RUN-PROGRAM...
  6. |#
  7. (in-package #:cl-deck-builder2.toolkit.git)
  8. (defparameter *git-directory*
  9. (relative-pathname ".git")
  10. "The base path to the directory we run git in during UIOP:RUN-PROGRAM.")
  11. (defparameter +git-binary+
  12. (format nil "git --no-pager --git-dir ~a" *git-directory*)
  13. "The full git command line, with *GIT-DIRECTORY* passed in already. What could go wrong?")
  14. (defparameter +git-log+
  15. (concatenate 'string
  16. +git-binary+
  17. " log --format=\"%h%nAuthor: %an%nDate: %cD%n%s%n%b%n----\"")
  18. "Full command line to git log.")
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. (defun git-revision ()
  21. "Query git rev-parse for the current HEAD revision id."
  22. (let ((command
  23. (concatenate 'string
  24. +git-binary+
  25. " rev-parse --short HEAD")))
  26. (string-trim '(#\Newline)
  27. (uiop:run-program command :output :string :error-output nil))))
  28. (defun git-log ()
  29. "Query git log into a somewhat parseable format."
  30. (cl-ppcre:split
  31. "\\n+----\\n"
  32. (uiop:run-program +git-log+ :output :string)))
  33. ;; Not terrible...
  34. (defun parse-git-log (msg)
  35. "Split the output of GIT-MESSAGES-LIST into an actual LIST.
  36. ARGUMENTS
  37. MSG The output of GIT-MESSAGES-LIST.
  38. SEE GIT-LOG"
  39. (let ((state :in-commit)
  40. (c '()))
  41. (loop for line in (split-sequence:split-sequence #\Newline msg) do
  42. (case state
  43. (:in-commit (setf (getf c :commit) line
  44. state :in-author))
  45. (:in-author (setf (getf c :author) line
  46. state :in-date))
  47. (:in-date (setf (getf c :date) line
  48. state :in-subject))
  49. (:in-subject (setf (getf c :subject) line
  50. state :in-message))
  51. (:in-message (setf (getf c :message)
  52. (format nil "~a~a~%"
  53. (getf c :message "")
  54. line)))))
  55. c))