| 110 | } |
| 111 | |
| 112 | func (h *Handler) ListFiles(predicate func(string) (bool, error)) ([]string, error) { |
| 113 | if err := h.setup(); err != nil { |
| 114 | return nil, fmt.Errorf("setup: %w", err) |
| 115 | } |
| 116 | var files []string |
| 117 | for _, f := range h.files { |
| 118 | shouldInclude, err := predicate(f) |
| 119 | if err != nil { |
| 120 | return nil, fmt.Errorf("error applying predicate to file %s: %w", f, err) |
| 121 | } |
| 122 | |
| 123 | if shouldInclude { |
| 124 | files = append(files, f) |
| 125 | } |
| 126 | } |
| 127 | return files, nil |
| 128 | } |
| 129 | |
| 130 | func enumerateFiles(repo *git.Repository) ([]string, error) { |
| 131 | ref, err := repo.Head() |