Merge branch 'loops/gitea' into architecture

This commit is contained in:
2026-07-03 18:44:53 +00:00

View File

@@ -12,7 +12,8 @@
; without re-pushing), import-push! sends the delta between the remote's ; without re-pushing), import-push! sends the delta between the remote's
; advertised head and the local one in a single request. Pushing per ; advertised head and the local one in a single request. Pushing per
; batch is quadratic (every push walks the full closure on both sides); ; batch is quadratic (every push walks the full closure on both sides);
; stage many, push once. ; stage many, push once. Import from an IMMUTABLE snapshot (git archive)
; — replaying against a live tree diverges the moment a file changes.
; ;
; Files whose pack line would exceed the pkt-line limit are skipped and ; Files whose pack line would exceed the pkt-line limit are skipped and
; reported per batch (wire limit; see lib/gitea/wire.sx). ; reported per batch (wire limit; see lib/gitea/wire.sx).
@@ -54,12 +55,12 @@
gitea/import-fits? gitea/import-fits?
(fn (data) (gitea/pkt-fits? (str "x" (serialize (git/blob data)))))) (fn (data) (gitea/pkt-fits? (str "x" (serialize (git/blob data))))))
; read + stage one manifest of paths and commit — NO push ; read + stage one manifest of paths and commit with the given message —
; => {:batch n :files k :skipped (paths) :cid commit-cid} ; NO push. => {:batch n :files k :skipped (paths) :cid commit-cid}
(define (define
gitea/import-stage! gitea/import-stage-msg!
(fn (fn
(root manifest) (root manifest message time)
(let (let
((st gitea/import-state)) ((st gitea/import-state))
(let (let
@@ -69,9 +70,21 @@
(let (let
((skipped (reduce (fn (acc p) (let ((data (file-read (str root "/" p)))) (if (gitea/import-fits? data) (begin (git/add! repo p data) acc) (append acc (list p))))) (list) paths))) ((skipped (reduce (fn (acc p) (let ((data (file-read (str root "/" p)))) (if (gitea/import-fits? data) (begin (git/add! repo p data) acc) (append acc (list p))))) (list) paths)))
(let (let
((cid (git/commit! repo {:message (str "import rose-ash: batch " n) :time n :author "giles"}))) ((cid (git/commit! repo {:message message :time time :author "giles"})))
(begin (set! gitea/import-state (assoc st :batch n)) {:batch n :files (- (len paths) (len skipped)) :skipped skipped :cid cid}))))))) (begin (set! gitea/import-state (assoc st :batch n)) {:batch n :files (- (len paths) (len skipped)) :skipped skipped :cid cid})))))))
(define
gitea/import-stage!
(fn
(root manifest)
(let
((n (+ 1 (get gitea/import-state :batch))))
(gitea/import-stage-msg!
root
manifest
(str "import rose-ash: batch " n)
n))))
; one delta push of everything staged since the remote's advertised head ; one delta push of everything staged since the remote's advertised head
(define (define
gitea/import-push! gitea/import-push!
@@ -81,6 +94,15 @@
((st gitea/import-state)) ((st gitea/import-state))
(gitea/push! (get st :remote) (get st :repo) "heads/main")))) (gitea/push! (get st :remote) (get st :repo) "heads/main"))))
; delete the remote branch (for replacing an import's history)
(define
gitea/import-delete-remote!
(fn
()
(let
((st gitea/import-state))
(gitea/push-delete! (get st :remote) (get st :repo) "heads/main"))))
; stage + push in one step (fine for small imports) ; stage + push in one step (fine for small imports)
(define (define
gitea/import-batch! gitea/import-batch!