blob: 422c10260ea5091542869209a8243d22bf68edc9 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
}
|