diff options
| author | Jeff Carr <[email protected]> | 2024-11-22 21:05:20 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-22 21:05:20 -0600 |
| commit | 8bf3997c81db88d8401db28c86f701be014442c2 (patch) | |
| tree | 9d9ab69ed59f8caf504da964ff16680b5c8482bf | |
| parent | 60695905e00ae230f7c345a49d036392a6b3f766 (diff) | |
repos.FindByName()v0.22.16
| -rw-r--r-- | common.go | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -25,7 +25,23 @@ func (r *RepoList) Hide() { } // better name: use this -func (r *RepoList) FindRepoByName(path string) *RepoRow { +// matches by path or by name +func (r *RepoList) FindByName(name string) *RepoRow { + loop := r.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + if repo.GoPath() == name { + return repo + } + base := filepath.Base(repo.GoPath()) + if base == name { + return repo + } + } + return nil +} + +func (r *RepoList) FindByPath(path string) *RepoRow { return r.FindRepo(path) } |
