ref: 1df19d6ebe4dccf7de3bcf16cf6037d169832ce3
parent: c82aa966fd5aca7c6c34bea21da5714916022475
author: Runxi Yu <me@runxiyu.org>
date: Sat Mar 7 23:08:36 EST 2026
receivepack: Trivial caps
--- /dev/null
+++ b/receivepack/capabilities_defaults.go
@@ -1,0 +1,17 @@
+package receivepack
+
+import (
+ "crypto/rand"
+)
+
+func defaultAgent() string {+ return "furgit"
+}
+
+func defaultSessionID() string {+ return "furgit-" + rand.Text()
+}
+
+func defaultPushCertNonce() string {+ return "furgit-" + rand.Text()
+}
--- a/receivepack/options.go
+++ b/receivepack/options.go
@@ -29,6 +29,19 @@
// Hook, when non-nil, runs after pack ingestion into quarantine and before
// quarantine promotion or ref updates.
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 {--- a/receivepack/receivepack.go
+++ b/receivepack/receivepack.go
@@ -37,6 +37,21 @@
Algorithm: opts.Algorithm,
})
+ agent := opts.Agent
+ if agent == "" {+ agent = defaultAgent()
+ }
+
+ sessionID := opts.SessionID
+ if sessionID == "" {+ sessionID = defaultSessionID()
+ }
+
+ pushCertNonce := opts.PushCertNonce
+ if pushCertNonce == "" {+ pushCertNonce = defaultPushCertNonce()
+ }
+
protoSession := protoreceive.NewSession(base, protoreceive.Capabilities{ReportStatus: true,
ReportStatusV2: true,
@@ -46,8 +61,10 @@
Atomic: true,
OfsDelta: true,
PushOptions: true,
+ PushCertNonce: pushCertNonce,
+ SessionID: sessionID,
ObjectFormat: opts.Algorithm,
- // TODO: PushCertNonce, SessionID, Agent, whatever.
+ Agent: agent,
})
refs, err := advertisedRefs(opts)
--
⑨