Add git interface function
authorFrank Duncan <frank@kank.net>
Fri, 10 Dec 2021 13:05:01 +0000 (07:05 -0600)
committerFrank Duncan <frank@kank.net>
Fri, 10 Dec 2021 13:05:01 +0000 (07:05 -0600)
candle.asd
src/main/git.lisp [new file with mode: 0644]

index 0dbb24c8319cb9347512a175fefcb9f707035c84..55de87568555b846f55afadd265b0494eabbe7dd 100644 (file)
@@ -5,5 +5,5 @@
  :author "Frank Duncan (frank@consxy.com)"
  :serial t
  :pathname "src/main"
  :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))
  :depends-on (:herbie-utility :opera))
diff --git a/src/main/git.lisp b/src/main/git.lisp
new file mode 100644 (file)
index 0000000..065eb40
--- /dev/null
@@ -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)))