diff options
author | Michael Muré <batolettre@gmail.com> | 2019-03-03 15:27:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-03 15:27:29 +0100 |
commit | fe8b0659c9bc1cb074a5acfbafcabd603e533f9f (patch) | |
tree | b3d8db1596b7347fdcf39cfdc9614a3c09464b36 /cache/filter.go | |
parent | 7260ca05bc3588c0572887a7d8f1b897c7fc13da (diff) | |
parent | 408654514ea813933f45d383d949611d138084e1 (diff) | |
download | git-bug-fe8b0659c9bc1cb074a5acfbafcabd603e533f9f.tar.gz |
Merge pull request #100 from sladyn98/faster_ls
`git bug ls` should be faster
Diffstat (limited to 'cache/filter.go')
-rw-r--r-- | cache/filter.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cache/filter.go b/cache/filter.go index 022a8ff2..b6872508 100644 --- a/cache/filter.go +++ b/cache/filter.go @@ -55,6 +55,16 @@ func LabelFilter(label string) Filter { } } +// TitleFilter return a Filter that match if the title contains the given query +func TitleFilter(query string) Filter { + return func(repo *RepoCache, excerpt *BugExcerpt) bool { + return strings.Contains( + strings.ToLower(excerpt.Title), + strings.ToLower(query), + ) + } +} + // NoLabelFilter return a Filter that match the absence of labels func NoLabelFilter() Filter { return func(repoCache *RepoCache, excerpt *BugExcerpt) bool { @@ -67,6 +77,7 @@ type Filters struct { Status []Filter Author []Filter Label []Filter + Title []Filter NoFilters []Filter } @@ -88,6 +99,10 @@ func (f *Filters) Match(repoCache *RepoCache, excerpt *BugExcerpt) bool { return false } + if match := f.andMatch(f.Title, repoCache, excerpt); !match { + return false + } + return true } |