diff options
| author | 2026-03-22 23:10:37 +0000 | |
|---|---|---|
| committer | 2026-03-22 23:13:19 +0000 | |
| commit | ab6f8dde0cdc554084c4455c76feef0099db70d9 (patch) | |
| tree | 6c6a207d6094a8d99b1b1b43f8bdee93c19871e0 /refstore/chain | |
| parent | commitgraph: Tighten docs and use a value-ish Filter return (diff) | |
| signature | No signature | |
*: Fixup ownership of compositional backends v0.1.88
Diffstat (limited to 'refstore/chain')
| -rw-r--r-- | refstore/chain/chain.go | 2 | ||||
| -rw-r--r-- | refstore/chain/close.go | 25 | ||||
| -rw-r--r-- | refstore/chain/list.go | 4 | ||||
| -rw-r--r-- | refstore/chain/new.go | 3 | ||||
| -rw-r--r-- | refstore/chain/resolve.go | 4 |
5 files changed, 11 insertions, 27 deletions
diff --git a/refstore/chain/chain.go b/refstore/chain/chain.go index 882d4b56..0feb97c3 100644 --- a/refstore/chain/chain.go +++ b/refstore/chain/chain.go @@ -5,6 +5,8 @@ package chain import "codeberg.org/lindenii/furgit/refstore" // Chain queries multiple reference stores in order. +// +// Chain borrows its backend stores. type Chain struct { backends []refstore.ReadingStore } diff --git a/refstore/chain/close.go b/refstore/chain/close.go index 440afb10..6bd74565 100644 --- a/refstore/chain/close.go +++ b/refstore/chain/close.go @@ -1,21 +1,8 @@ package chain -import "errors" - -// Close closes all backends and joins close errors. -func (chain *Chain) Close() error { - var errs []error - - for _, backend := range chain.backends { - if backend == nil { - continue - } - - err := backend.Close() - if err != nil { - errs = append(errs, err) - } - } - - return errors.Join(errs...) -} +// Close releases wrapper-local resources. +// +// Chain borrows its backends, so Close does not close them. +// +// Repeated calls to Close are undefined behavior. +func (chain *Chain) Close() error { return nil } diff --git a/refstore/chain/list.go b/refstore/chain/list.go index e1594e95..c577ca85 100644 --- a/refstore/chain/list.go +++ b/refstore/chain/list.go @@ -15,10 +15,6 @@ func (chain *Chain) List(pattern string) ([]ref.Ref, error) { seen := map[string]struct{}{} for i, backend := range chain.backends { - if backend == nil { - continue - } - listed, err := backend.List(pattern) if err != nil { return nil, fmt.Errorf("refstore: backend %d list: %w", i, err) diff --git a/refstore/chain/new.go b/refstore/chain/new.go index ebf5e2bb..f8bdcb13 100644 --- a/refstore/chain/new.go +++ b/refstore/chain/new.go @@ -3,6 +3,9 @@ package chain import "codeberg.org/lindenii/furgit/refstore" // New creates an ordered reference store chain. +// +// The provided backends must be non-nil and distinct. +// Chain borrows the provided backends and does not close them in Close. func New(backends ...refstore.ReadingStore) *Chain { return &Chain{ backends: append([]refstore.ReadingStore(nil), backends...), diff --git a/refstore/chain/resolve.go b/refstore/chain/resolve.go index 99ada284..97dee24b 100644 --- a/refstore/chain/resolve.go +++ b/refstore/chain/resolve.go @@ -13,10 +13,6 @@ import ( //nolint:ireturn func (chain *Chain) Resolve(name string) (ref.Ref, error) { for i, backend := range chain.backends { - if backend == nil { - continue - } - resolved, err := backend.Resolve(name) if err == nil { return resolved, nil |
