mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-03 00:45:22 +02:00
feat(issue search): query string for boolean operators and phrase search (#6952)
closes #6909 related to forgejo/design#14 # Description Adds the following boolean operators for issues when using an indexer (with minor caveats) - `+term`: `term` MUST be present for any result - `-term`: negation; exclude results that contain `term` - `"this is a term"`: matches the exact phrase `this is a term` In all cases the special characters may be escaped by the prefix `\` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6952 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Reviewed-by: Otto <otto@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
eaa641c21e
commit
cddf608cb9
19 changed files with 451 additions and 192 deletions
|
@ -138,27 +138,25 @@ func TestViewIssuesKeyword(t *testing.T) {
|
|||
})
|
||||
|
||||
// keyword: 'firstt'
|
||||
// should not match when fuzzy searching is disabled
|
||||
req = NewRequestf(t, "GET", "%s/issues?q=%st&fuzzy=false", repo.Link(), keyword)
|
||||
// should not match when using phrase search
|
||||
req = NewRequestf(t, "GET", "%s/issues?q=\"%st\"", repo.Link(), keyword)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
issuesSelection = getIssuesSelection(t, htmlDoc)
|
||||
assert.EqualValues(t, 0, issuesSelection.Length())
|
||||
|
||||
// should match as 'first' when fuzzy seaeching is enabled
|
||||
for _, fmt := range []string{"%s/issues?q=%st&fuzzy=true", "%s/issues?q=%st"} {
|
||||
req = NewRequestf(t, "GET", fmt, repo.Link(), keyword)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
issuesSelection = getIssuesSelection(t, htmlDoc)
|
||||
assert.EqualValues(t, 1, issuesSelection.Length())
|
||||
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
|
||||
issue := getIssue(t, repo.ID, selection)
|
||||
assert.False(t, issue.IsClosed)
|
||||
assert.False(t, issue.IsPull)
|
||||
assertMatch(t, issue, keyword)
|
||||
})
|
||||
}
|
||||
// should match as 'first' when using a standard query
|
||||
req = NewRequestf(t, "GET", "%s/issues?q=%st", repo.Link(), keyword)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
issuesSelection = getIssuesSelection(t, htmlDoc)
|
||||
assert.EqualValues(t, 1, issuesSelection.Length())
|
||||
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
|
||||
issue := getIssue(t, repo.ID, selection)
|
||||
assert.False(t, issue.IsClosed)
|
||||
assert.False(t, issue.IsPull)
|
||||
assertMatch(t, issue, keyword)
|
||||
})
|
||||
}
|
||||
|
||||
func TestViewIssuesSearchOptions(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue