From b82515530f10dfebbf99dca501890570f3466910 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 7 Mar 2026 21:15:54 +0800 Subject: receivepack: Add hooks --- receivepack/hook.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 receivepack/hook.go (limited to 'receivepack/hook.go') 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) -- cgit v1.3.1-10-gc9f91