aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--receivepack/capabilities_defaults.go17
-rw-r--r--receivepack/options.go13
-rw-r--r--receivepack/receivepack.go19
3 files changed, 48 insertions, 1 deletions
diff --git a/receivepack/capabilities_defaults.go b/receivepack/capabilities_defaults.go
new file mode 100644
index 00000000..72c36c30
--- /dev/null
+++ b/receivepack/capabilities_defaults.go
@@ -0,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()
+}
diff --git a/receivepack/options.go b/receivepack/options.go
index f55fbad1..7328f770 100644
--- a/receivepack/options.go
+++ b/receivepack/options.go
@@ -29,6 +29,19 @@ type Options struct {
// 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 {
diff --git a/receivepack/receivepack.go b/receivepack/receivepack.go
index 42095e1b..27c71660 100644
--- a/receivepack/receivepack.go
+++ b/receivepack/receivepack.go
@@ -37,6 +37,21 @@ func ReceivePack(
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 @@ func ReceivePack(
Atomic: true,
OfsDelta: true,
PushOptions: true,
+ PushCertNonce: pushCertNonce,
+ SessionID: sessionID,
ObjectFormat: opts.Algorithm,
- // TODO: PushCertNonce, SessionID, Agent, whatever.
+ Agent: agent,
})
refs, err := advertisedRefs(opts)