aboutsummaryrefslogtreecommitdiff
path: root/receivepack/hook.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-07 21:15:54 +0800
committerGravatar Runxi Yu2026-03-07 21:16:32 +0800
commitb82515530f10dfebbf99dca501890570f3466910 (patch)
tree9574dc49fa7239f7f0c131471f4a6708fd7041d5 /receivepack/hook.go
parentreceivepack: Set permissions properly (diff)
signatureNo signature
receivepack: Add hooks
Diffstat (limited to 'receivepack/hook.go')
-rw-r--r--receivepack/hook.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/receivepack/hook.go b/receivepack/hook.go
new file mode 100644
index 00000000..4c4a44ef
--- /dev/null
+++ b/receivepack/hook.go
@@ -0,0 +1,39 @@
+package receivepack
+
+import (
+ "context"
+
+ "codeberg.org/lindenii/furgit/objectid"
+ "codeberg.org/lindenii/furgit/objectstore"
+ "codeberg.org/lindenii/furgit/refstore"
+)
+
+// RefUpdate is one requested reference update presented to a receive-pack hook.
+type RefUpdate struct {
+ Name string
+ OldID objectid.ObjectID
+ NewID objectid.ObjectID
+}
+
+// UpdateDecision is one hook decision for a requested reference update.
+type UpdateDecision struct {
+ Accept bool
+ Message string
+}
+
+// HookRequest is the input presented to a receive-pack hook before quarantine
+// promotion and ref updates.
+type HookRequest struct {
+ Refs refstore.ReadingStore
+ ExistingObjects objectstore.Store
+ QuarantinedObjects objectstore.Store
+ Updates []RefUpdate
+ PushOptions []string
+}
+
+// Hook decides whether each requested update should proceed.
+//
+// The hook runs after pack ingestion into quarantine and before quarantine
+// promotion or ref updates. The returned decisions must have the same length as
+// HookRequest.Updates.
+type Hook func(context.Context, HookRequest) ([]UpdateDecision, error)