From 466f798b43a50f1febcab5518d8c8e1983ff9f3a Mon Sep 17 00:00:00 2001 From: Frank Duncan Date: Fri, 10 Dec 2021 07:05:01 -0600 Subject: [PATCH] Add git interface function --- candle.asd | 2 +- src/main/git.lisp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/main/git.lisp diff --git a/candle.asd b/candle.asd index 0dbb24c..55de875 100644 --- a/candle.asd +++ b/candle.asd @@ -5,5 +5,5 @@ :author "Frank Duncan (frank@consxy.com)" :serial t :pathname "src/main" - :components ((:file "package") (:file "base") (:file "server") (:file "cli") (:file "run")) + :components ((:file "package") (:file "base") (:file "server") (:file "cli") (:file "git") (:file "run")) :depends-on (:herbie-utility :opera)) diff --git a/src/main/git.lisp b/src/main/git.lisp new file mode 100644 index 0000000..065eb40 --- /dev/null +++ b/src/main/git.lisp @@ -0,0 +1,25 @@ +(in-package #:candle) + +(defvar *git-location* "/usr/bin/git") + +(defun git (project cmd &rest args) + (let + ((err nil) + (out nil) + (code nil)) + (setf + err + (with-output-to-string (err-str) + (setf out + (with-output-to-string (out-str) + (setf code + (sb-ext:process-exit-code + (sb-ext:run-program *git-location* + (append + (list "-C" (if project (project-dir project) *candle-dir*)) + (list cmd) + args) + :output out-str + :error err-str + :wait t))))))) + (values (zerop code) code out err))) -- 2.25.1