Browse code
feat(blobs): introduce BLOB class
Edward authored on 02/06/2021 06:19:00
Showing 5 changed files
Showing 5 changed files
... | ... |
@@ -24,7 +24,7 @@ |
24 | 24 |
|
25 | 25 |
;; data model |
26 | 26 |
(:file "model" :depends-on ("package")) |
27 |
- (:file "protocol" :depends-on ("package" "model")) |
|
27 |
+ (:file "protocol" :depends-on ("package" "model" "util")) |
|
28 | 28 |
(:file "repository" :depends-on ("package" "model")) |
29 | 29 |
(:file "tree" :depends-on ("package" "model" "protocol")) |
30 | 30 |
(:file "commit" :depends-on ("package" "model" "protocol")) |
... | ... |
@@ -1,19 +1,5 @@ |
1 | 1 |
(in-package :fwoar.cl-git) |
2 | 2 |
|
3 |
-(defmacro defclass+ (name (&rest super) &body (direct-slots &rest options)) |
|
4 |
- (let ((initargs (mapcan (lambda (slot) |
|
5 |
- (serapeum:unsplice |
|
6 |
- (make-symbol |
|
7 |
- (symbol-name |
|
8 |
- (getf (cdr slot) |
|
9 |
- :initarg))))) |
|
10 |
- direct-slots))) |
|
11 |
- `(progn (defclass ,name ,super |
|
12 |
- ,direct-slots |
|
13 |
- ,@options) |
|
14 |
- (defun ,name (,@initargs) |
|
15 |
- (fw.lu:new ',name ,@initargs))))) |
|
16 |
- |
|
17 | 3 |
(defclass delta () |
18 | 4 |
((%repository :initarg :repository :reader repository) |
19 | 5 |
(%base :initarg :base :reader base) |
... | ... |
@@ -1,8 +1,11 @@ |
1 | 1 |
(in-package :fwoar.cl-git) |
2 | 2 |
|
3 |
+(defclass+ blob () |
|
4 |
+ ((%data :reader data :initarg :data))) |
|
5 |
+ |
|
3 | 6 |
(defgeneric -extract-object-of-type (type s repository &key &allow-other-keys) |
4 | 7 |
(:method ((type (eql :blob)) s repository &key) |
5 |
- s) |
|
8 |
+ (blob s)) |
|
6 | 9 |
|
7 | 10 |
(:method ((type (eql :tag)) s repository &key) |
8 | 11 |
s)) |
... | ... |
@@ -141,12 +141,13 @@ |
141 | 141 |
(fiveam:is (equal hash (fwoar.cl-git::ref-hash ref))) |
142 | 142 |
(fiveam:is (equal *fake-repo* (fwoar.cl-git::ref-repo ref))) |
143 | 143 |
(fwoar.cl-git::extract-object ref)))) |
144 |
- (5am:is (typep object '(vector (unsigned-byte 8)))) |
|
144 |
+ (5am:is (typep object 'fwoar.cl-git::blob)) |
|
145 | 145 |
(5am:is (equal "hello, world |
146 | 146 |
" |
147 | 147 |
(babel:octets-to-string |
148 |
- (fwoar.cl-git::extract-object |
|
149 |
- (fwoar.cl-git::packed-ref |
|
150 |
- :fwoar.cl-git.git-objects.pack |
|
151 |
- "4b5fa63702dd96796042e92787f464e28f09f17d")) |
|
148 |
+ (fwoar.cl-git::data |
|
149 |
+ (fwoar.cl-git::extract-object |
|
150 |
+ (fwoar.cl-git::packed-ref |
|
151 |
+ :fwoar.cl-git.git-objects.pack |
|
152 |
+ "4b5fa63702dd96796042e92787f464e28f09f17d"))) |
|
152 | 153 |
:encoding :utf-8))))) |
... | ... |
@@ -1,5 +1,19 @@ |
1 | 1 |
(in-package :fwoar.cl-git) |
2 | 2 |
|
3 |
+(defmacro defclass+ (name (&rest super) &body (direct-slots &rest options)) |
|
4 |
+ (let ((initargs (mapcan (lambda (slot) |
|
5 |
+ (serapeum:unsplice |
|
6 |
+ (make-symbol |
|
7 |
+ (symbol-name |
|
8 |
+ (getf (cdr slot) |
|
9 |
+ :initarg))))) |
|
10 |
+ direct-slots))) |
|
11 |
+ `(progn (defclass ,name ,super |
|
12 |
+ ,direct-slots |
|
13 |
+ ,@options) |
|
14 |
+ (defun ,name (,@initargs) |
|
15 |
+ (fw.lu:new ',name ,@initargs))))) |
|
16 |
+ |
|
3 | 17 |
(fw.lu:defun-ct batch-4 (bytes) |
4 | 18 |
(mapcar 'fwoar.bin-parser:be->int |
5 | 19 |
(serapeum:batches bytes 4))) |
... | ... |
@@ -31,7 +45,7 @@ |
31 | 45 |
(defun partition (char string &key from-end (with-offset nil wo-p)) |
32 | 46 |
(let ((pos (position char string :from-end from-end))) |
33 | 47 |
(if pos |
34 |
- (if wo-p |
|
48 |
+ (if wo-p |
|
35 | 49 |
(list (subseq string 0 (+ pos with-offset 1)) |
36 | 50 |
(subseq string (+ pos 1 with-offset))) |
37 | 51 |
(list (subseq string 0 pos) |