diff options
author | Michael Muré <batolettre@gmail.com> | 2021-02-27 20:39:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-27 20:39:27 +0100 |
commit | 22cc4cc043370bac945f92ecf343025ce7fdfe33 (patch) | |
tree | a0162d685c22d274dd4e5916d8cf46136c7dc0ea /cache | |
parent | 10a259b6823e1234e5add1ee62935f259c39f803 (diff) | |
parent | fab626a7a663a8fa6ef27848bb63e91af812ab8c (diff) | |
download | git-bug-22cc4cc043370bac945f92ecf343025ce7fdfe33.tar.gz |
Merge pull request #568 from vmiklos/search-metadata
Add ability to search by arbitrary metadata
Diffstat (limited to 'cache')
-rw-r--r-- | cache/filter.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cache/filter.go b/cache/filter.go index 2ac56ab5..c167fe71 100644 --- a/cache/filter.go +++ b/cache/filter.go @@ -38,6 +38,16 @@ func AuthorFilter(query string) Filter { } } +// MetadataFilter return a Filter that match a bug metadata at creation time +func MetadataFilter(pair query.StringPair) Filter { + return func(excerpt *BugExcerpt, resolver resolver) bool { + if value, ok := excerpt.CreateMetadata[pair.Key]; ok { + return value == pair.Value + } + return false + } +} + // LabelFilter return a Filter that match a label func LabelFilter(label string) Filter { return func(excerpt *BugExcerpt, resolver resolver) bool { @@ -109,6 +119,7 @@ func NoLabelFilter() Filter { type Matcher struct { Status []Filter Author []Filter + Metadata []Filter Actor []Filter Participant []Filter Label []Filter @@ -127,6 +138,9 @@ func compileMatcher(filters query.Filters) *Matcher { for _, value := range filters.Author { result.Author = append(result.Author, AuthorFilter(value)) } + for _, value := range filters.Metadata { + result.Metadata = append(result.Metadata, MetadataFilter(value)) + } for _, value := range filters.Actor { result.Actor = append(result.Actor, ActorFilter(value)) } @@ -153,6 +167,10 @@ func (f *Matcher) Match(excerpt *BugExcerpt, resolver resolver) bool { return false } + if match := f.orMatch(f.Metadata, excerpt, resolver); !match { + return false + } + if match := f.orMatch(f.Participant, excerpt, resolver); !match { return false } |