8// PatternInfo is an interface for types that represent glob patterns
9type PatternInfo interface {
12 isPattern() // marker method
15// StringPattern implements PatternInfo for string patterns
16type StringPattern struct {
20func (p StringPattern) GetPattern() string { return p.Pattern }
21func (p StringPattern) GetBasePath() string { return "" }
22func (p StringPattern) isPattern() {}
24// RelativePatternInfo implements PatternInfo for RelativePattern
25type RelativePatternInfo struct {
30func (p RelativePatternInfo) GetPattern() string { return string(p.RP.Pattern) }
31func (p RelativePatternInfo) GetBasePath() string { return p.BasePath }
32func (p RelativePatternInfo) isPattern() {}
34// AsPattern converts GlobPattern to a PatternInfo object
35func (g *GlobPattern) AsPattern() (PatternInfo, error) {
37 return nil, fmt.Errorf("nil pattern")
40 switch v := g.Value.(type) {
42 return StringPattern{Pattern: v}, nil
44 // Handle BaseURI which could be string or DocumentUri
46 switch baseURI := v.BaseURI.Value.(type) {
48 basePath = strings.TrimPrefix(baseURI, "file://")
50 basePath = strings.TrimPrefix(string(baseURI), "file://")
52 return nil, fmt.Errorf("unknown BaseURI type: %T", v.BaseURI.Value)
54 return RelativePatternInfo{RP: v, BasePath: basePath}, nil
56 return nil, fmt.Errorf("unknown pattern type: %T", g.Value)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list