diff options
| author | 2026-03-07 21:15:54 +0800 | |
|---|---|---|
| committer | 2026-03-07 21:16:32 +0800 | |
| commit | b82515530f10dfebbf99dca501890570f3466910 (patch) | |
| tree | 9574dc49fa7239f7f0c131471f4a6708fd7041d5 /receivepack/hook.go | |
| parent | receivepack: Set permissions properly (diff) | |
| signature | No signature | |
receivepack: Add hooks
Diffstat (limited to 'receivepack/hook.go')
| -rw-r--r-- | receivepack/hook.go | 39 |
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) |
