git.fiddlerwoaroof.com
Browse code

chore: fix porcelain

Ed Langley authored on 29/10/2020 21:50:11
Showing 1 changed files
... ...
@@ -20,18 +20,26 @@
20 20
   (intern (symbol-name symbol)
21 21
           :git))
22 22
 
23
+(defun handle-list (_1)
24
+  (case (in-git-package (car _1))
25
+    (git::unwrap `(uiop:nest (car)
26
+                             (mapcar ,@(cdr _1))))
27
+    (t (cons (in-git-package (car _1))
28
+             (cdr _1)))))
29
+
23 30
 (defmacro git:git (&rest commands)
24 31
   `(uiop:nest ,@(reverse
25 32
                  (mapcar (serapeum:op
26 33
                            (typecase _1
27 34
                              (string `(identity ,_1))
28
-                             (list (case (in-git-package (car _1))
29
-                                     (git::unwrap `(uiop:nest (car)
30
-                                                              (mapcar ,@(cdr _1))))
31
-                                     (t (cons (in-git-package (car _1))
32
-                                              (cdr _1)))))))
35
+                             (list (handle-list _1))))
33 36
                          commands))))
34 37
 
38
+(defun ensure-ref (thing &optional (repo (repository *git-repository*)))
39
+  (typecase thing
40
+    (git-ref thing)
41
+    (t (ref repo thing))))
42
+
35 43
 (defun git::ensure-ref (it)
36 44
   (ensure-ref it))
37 45
 
... ...
@@ -57,14 +65,19 @@
57 65
                          `(,@(alexandria:ensure-list f) ,arg))
58 66
                        funs)))))
59 67
 
68
+(defmacro git::pipe (&rest funs)
69
+  (let ((funs (reverse (butlast funs)))
70
+        (var (car (last funs))))
71
+    `(uiop:nest ,@(mapcar (lambda (it)
72
+                            (if (consp it)
73
+                                `(,(in-git-package (car it)) ,@(cdr it))
74
+                                `(,(in-git-package it))))
75
+                          funs)
76
+                ,var)))
77
+
60 78
 (defun git::filter (fun &rest args)
61 79
   (apply #'remove-if-not fun args))
62 80
 
63
-(defun ensure-ref (thing &optional (repo (repository *git-repository*)))
64
-  (typecase thing
65
-    (git-ref thing)
66
-    (t (ref repo thing))))
67
-
68 81
 (defun git::object (thing)
69 82
   (extract-object thing))
70 83
 
... ...
@@ -115,5 +128,7 @@
115 128
 (defun git:branches ()
116 129
   (branches (repository *git-repository*)))
117 130
 
131
+(defun git::parents (commit)
132
+  (alexandria:mappend 'cdr (component :parents commit)))
118 133
 (defun git:commit-parents (commit)
119
-  (mapcar 'cdr (component :parents commit)))
134
+  (git::parents commit))