diff options
| author | 2026-03-04 12:52:26 +0800 | |
|---|---|---|
| committer | 2026-03-04 12:52:26 +0800 | |
| commit | b3028bc65ac03b0bb4a88482519fb45700c675f3 (patch) | |
| tree | 137391bcb8a0c7f63aefb0fc7221720ae6f894d2 /refstore/packed/list.go | |
| parent | repository: Split (diff) | |
| signature | No signature | |
refstore/packed: Split
Diffstat (limited to 'refstore/packed/list.go')
| -rw-r--r-- | refstore/packed/list.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/refstore/packed/list.go b/refstore/packed/list.go new file mode 100644 index 00000000..422c1026 --- /dev/null +++ b/refstore/packed/list.go @@ -0,0 +1,39 @@ +package packed + +import ( + "path" + + "codeberg.org/lindenii/furgit/ref" +) + +// List lists packed references matching pattern. +// +// Pattern uses path.Match syntax against full reference names. +// Empty pattern matches all references. +func (store *Store) List(pattern string) ([]ref.Ref, error) { + matchAll := pattern == "" + if !matchAll { + _, err := path.Match(pattern, "refs/heads/main") + if err != nil { + return nil, err + } + } + + refs := make([]ref.Ref, 0, len(store.ordered)) + for _, entry := range store.ordered { + if !matchAll { + matched, err := path.Match(pattern, entry.Name()) + if err != nil { + return nil, err + } + + if !matched { + continue + } + } + + refs = append(refs, entry) + } + + return refs, nil +} |
