aboutsummaryrefslogtreecommitdiff
path: root/network/receivepack/options.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-26 09:14:59 +0000
committerGravatar Runxi Yu2026-03-26 09:14:59 +0000
commit3d25bda9d5da6814661828adabe8a09f9d01aefb (patch)
treed034e28079333f85e5d7b96d921282eddd4798d6 /network/receivepack/options.go
parentobject/id: Empty tree (diff)
signatureNo signature
network/receivepack: Rename from receivepack
Diffstat (limited to 'network/receivepack/options.go')
-rw-r--r--network/receivepack/options.go68
1 files changed, 68 insertions, 0 deletions
diff --git a/network/receivepack/options.go b/network/receivepack/options.go
new file mode 100644
index 00000000..139c3839
--- /dev/null
+++ b/network/receivepack/options.go
@@ -0,0 +1,68 @@
+package receivepack
+
+import (
+ "os"
+
+ objectid "codeberg.org/lindenii/furgit/object/id"
+ objectstorer "codeberg.org/lindenii/furgit/object/storer"
+ refstore "codeberg.org/lindenii/furgit/ref/store"
+)
+
+// Options configures one receive-pack invocation.
+//
+// ReceivePack borrows all configured dependencies.
+//
+// Refs and ExistingObjects are required and must be non-nil.
+// ObjectsRoot is required if the invocation may need to ingest or promote a
+// pack.
+type Options struct {
+ // GitProtocol is the raw Git protocol version string from the transport,
+ // such as "version=1".
+ GitProtocol string
+ // Algorithm is the repository object ID algorithm used by the push session.
+ Algorithm objectid.Algorithm
+ // Refs is the reference store visible to the push.
+ Refs refstore.ReadWriteStore
+ // ExistingObjects is the object store visible to the push before any newly
+ // uploaded quarantined objects are promoted.
+ ExistingObjects objectstorer.Store
+ // ObjectsRoot is the permanent object storage root beneath which per-push
+ // quarantine directories are derived.
+ ObjectsRoot *os.Root
+ // PromotedObjectPermissions, when non-nil, is applied to objects and
+ // directories moved from quarantine into the permanent object store.
+ PromotedObjectPermissions *PromotedObjectPermissions
+ // Hook, when non-nil, runs after pack ingestion into quarantine and before
+ // quarantine promotion or ref updates. Hook is borrowed for the duration of
+ // ReceivePack.
+ Hook Hook
+ // Agent is the receive-pack agent string advertised via capability.
+ //
+ // When empty, ReceivePack derives one from build info and falls back to
+ // "furgit".
+ Agent string
+ // SessionID is the advertised receive-pack session-id capability value.
+ //
+ // When empty, ReceivePack generates one random value per invocation.
+ SessionID string
+ // PushCertNonce is the advertised push-cert nonce capability value.
+ //
+ // When empty, ReceivePack generates one random value per invocation.
+ PushCertNonce string
+}
+
+func validateOptions(opts Options) error {
+ if opts.Algorithm == 0 {
+ return ErrMissingAlgorithm
+ }
+
+ if opts.Refs == nil {
+ return ErrMissingRefs
+ }
+
+ if opts.ExistingObjects == nil {
+ return ErrMissingObjects
+ }
+
+ return nil
+}