mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
feat(issue-search): support query syntax (#9109)
List of currently supported filters: - `is:open` (or `-is:closed`) - `is:closed` (or `-is:open`) - `is:all` - `author:<username>` - `assignee:<username>` - `review:<username>` - `mentions:<username>` - `modified:[>|<]<date>`, where `<date>` is the last update date. - `sort:<by>:[asc|desc]`, where `<by>` is among - created - comments - updated - deadline Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9109 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Reviewed-by: Ellen Εμιλία Άννα Zscheile <fogti@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
parent
4d0c7db6cd
commit
255ed593d3
26 changed files with 870 additions and 296 deletions
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
package util
|
||||
|
||||
import "unsafe"
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func isSnakeCaseUpper(c byte) bool {
|
||||
return 'A' <= c && c <= 'Z'
|
||||
|
|
@ -117,3 +121,37 @@ func ASCIILower(b byte) byte {
|
|||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func RemoveAllStr(s string, prefix bool, all ...string) string {
|
||||
if len(s) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
sb, first := strings.Builder{}, true
|
||||
for field := range strings.FieldsSeq(s) {
|
||||
if hasAny(field, prefix, all...) {
|
||||
continue
|
||||
}
|
||||
if first {
|
||||
first = false
|
||||
goto write
|
||||
}
|
||||
sb.WriteRune(' ')
|
||||
write:
|
||||
sb.WriteString(field)
|
||||
}
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func hasAny(s string, prefix bool, all ...string) bool {
|
||||
if !prefix {
|
||||
return slices.Contains(all, s)
|
||||
}
|
||||
|
||||
for _, field := range all {
|
||||
if strings.HasPrefix(s, field) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue