diff options
| author | 2026-03-26 09:14:59 +0000 | |
|---|---|---|
| committer | 2026-03-26 09:14:59 +0000 | |
| commit | 3d25bda9d5da6814661828adabe8a09f9d01aefb (patch) | |
| tree | d034e28079333f85e5d7b96d921282eddd4798d6 /network/receivepack/service/hook.go | |
| parent | object/id: Empty tree (diff) | |
| signature | No signature | |
network/receivepack: Rename from receivepack
Diffstat (limited to 'network/receivepack/service/hook.go')
| -rw-r--r-- | network/receivepack/service/hook.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/network/receivepack/service/hook.go b/network/receivepack/service/hook.go new file mode 100644 index 00000000..750720dd --- /dev/null +++ b/network/receivepack/service/hook.go @@ -0,0 +1,45 @@ +package service + +import ( + "context" + "io" + + objectid "codeberg.org/lindenii/furgit/object/id" + objectstorer "codeberg.org/lindenii/furgit/object/storer" + refstore "codeberg.org/lindenii/furgit/ref/store" +) + +type HookIO struct { + Progress io.Writer + Error io.Writer +} + +type RefUpdate struct { + Name string + OldID objectid.ObjectID + NewID objectid.ObjectID +} + +type UpdateDecision struct { + Accept bool + Message string +} + +// HookRequest is the borrowed view passed to one Hook invocation. +// +// Refs, ExistingObjects, and QuarantinedObjects are borrowed and are only +// valid for the duration of the hook call. +type HookRequest struct { + Refs refstore.ReadingStore + ExistingObjects objectstorer.Store + QuarantinedObjects objectstorer.Store + Updates []RefUpdate + PushOptions []string + IO HookIO +} + +// Hook is an optional per-request validation hook. +// +// Hook borrows the data and stores in HookRequest only for the duration of the +// call. +type Hook func(context.Context, HookRequest) ([]UpdateDecision, error) |
