git.fiddlerwoaroof.com
protocol.lisp
1121b09a
 (in-package :fwoar.cl-git.protocol)
657ab332
 
489818ad
 (defgeneric -extract-object-of-type (type s repository &key  &allow-other-keys)
   (:method :around (type s repository &key hash)
     (let ((result (call-next-method)))
       (prog1 result
4b9f8a8a
         (when (typep result 'fwoar.cl-git:git-object)
           (setf (fwoar.cl-git:hash result) hash)))))
489818ad
 
4cc1ee49
 
   (:method ((type (eql :tag)) s repository &key)
     s))
 
 (defgeneric component (component object)
   (:argument-precedence-order object component)
a4381604
   (:method (component (object fwoar.cl-git.ref:ref))
4b9f8a8a
     (component component (fwoar.cl-git:extract-object object)))
4cc1ee49
   (:method ((component sequence) object)
     (reduce (lambda (cur next)
               (component next cur))
             component
             :initial-value object)))
9dca83b1
 
 
 (defmacro defcomponent (component &body body)
   (declare (ignore component body))
   (error "defcomponent not available on its own"))
 (defmacro defcomponents (class (object-sym component-sym) &body clauses)
   `(macrolet ((defcomponent (component &body component-body)
                 `(defmethod component ((,',component-sym ,component)
                                        (,',object-sym ,',class))
                    ,@component-body)))
      ,@(loop for (component . component-body) in clauses
              collect `(defcomponent ,component
                         ,@component-body))))