mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
Merge pull request #121 from A-Hilaly/query-humanid
Support matching identities with ID and truncated ID
This commit is contained in:
commit
16d2b92f05
11
cache/filter.go
vendored
11
cache/filter.go
vendored
@ -33,8 +33,7 @@ func AuthorFilter(query string) Filter {
|
|||||||
panic("missing identity in the cache")
|
panic("missing identity in the cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Contains(strings.ToLower(author.Name), query) ||
|
return author.Match(query)
|
||||||
strings.Contains(strings.ToLower(author.Login), query)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy identity support
|
// Legacy identity support
|
||||||
@ -66,9 +65,7 @@ func ActorFilter(query string) Filter {
|
|||||||
panic("missing identity in the cache")
|
panic("missing identity in the cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
if query == identityExcerpt.Id ||
|
if identityExcerpt.Match(query) {
|
||||||
strings.Contains(strings.ToLower(identityExcerpt.Name), query) ||
|
|
||||||
query == strings.ToLower(identityExcerpt.Login) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,9 +84,7 @@ func ParticipantFilter(query string) Filter {
|
|||||||
panic("missing identity in the cache")
|
panic("missing identity in the cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
if query == identityExcerpt.Id ||
|
if identityExcerpt.Match(query) {
|
||||||
strings.Contains(strings.ToLower(identityExcerpt.Name), query) ||
|
|
||||||
query == strings.ToLower(identityExcerpt.Login) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
cache/identity_excerpt.go
vendored
8
cache/identity_excerpt.go
vendored
@ -3,6 +3,7 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/MichaelMure/git-bug/identity"
|
"github.com/MichaelMure/git-bug/identity"
|
||||||
)
|
)
|
||||||
@ -51,6 +52,13 @@ func (i *IdentityExcerpt) DisplayName() string {
|
|||||||
panic("invalid person data")
|
panic("invalid person data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Match matches a query with the identity name, login and ID prefixes
|
||||||
|
func (i *IdentityExcerpt) Match(query string) bool {
|
||||||
|
return strings.HasPrefix(i.Id, query) ||
|
||||||
|
strings.Contains(strings.ToLower(i.Name), query) ||
|
||||||
|
strings.Contains(strings.ToLower(i.Login), query)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sorting
|
* Sorting
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ A few tips:
|
|||||||
- queries are case insensitive.
|
- queries are case insensitive.
|
||||||
- you can combine as many qualifiers as you want.
|
- you can combine as many qualifiers as you want.
|
||||||
- you can use double quotes for multi-word search terms. For example, `author:"René Descartes"` searches for bugs opened by René Descartes, whereas `author:René Descartes` will throw an error since full-text search is not yet supported.
|
- you can use double quotes for multi-word search terms. For example, `author:"René Descartes"` searches for bugs opened by René Descartes, whereas `author:René Descartes` will throw an error since full-text search is not yet supported.
|
||||||
|
- instead of a complete ID, you can use any prefix length. For example `participant=9ed1a`.
|
||||||
|
|
||||||
|
|
||||||
## Filtering
|
## Filtering
|
||||||
|
Loading…
Reference in New Issue
Block a user