aboutsummaryrefslogtreecommitdiff
path: root/ref/store/chain/list.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-25 14:31:16 +0000
committerGravatar Runxi Yu2026-03-25 14:31:16 +0000
commit48ff647cf4a8bb8f23fcd6b8616f56a8ef72b980 (patch)
treeae199c38042adaa544d5f7d31351661d5831381e /ref/store/chain/list.go
parent*: objectstore -> object/store (diff)
signatureNo signature
*: refstore -> ref/store
Diffstat (limited to 'ref/store/chain/list.go')
-rw-r--r--ref/store/chain/list.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/ref/store/chain/list.go b/ref/store/chain/list.go
new file mode 100644
index 00000000..c577ca85
--- /dev/null
+++ b/ref/store/chain/list.go
@@ -0,0 +1,40 @@
+package chain
+
+import (
+ "fmt"
+
+ "codeberg.org/lindenii/furgit/ref"
+)
+
+// List lists references from every backend and deduplicates by ref name.
+//
+// First-seen wins, so earlier backends have precedence.
+func (chain *Chain) List(pattern string) ([]ref.Ref, error) {
+ var refs []ref.Ref
+
+ seen := map[string]struct{}{}
+
+ for i, backend := range chain.backends {
+ listed, err := backend.List(pattern)
+ if err != nil {
+ return nil, fmt.Errorf("refstore: backend %d list: %w", i, err)
+ }
+
+ for _, entry := range listed {
+ if entry == nil {
+ continue
+ }
+
+ name := entry.Name()
+ if _, ok := seen[name]; ok {
+ continue
+ }
+
+ seen[name] = struct{}{}
+
+ refs = append(refs, entry)
+ }
+ }
+
+ return refs, nil
+}