Skip to content

Commit 56cdc36

Browse files
committed
refactor(pkg/search): rename KeywordsVerbatim to ImmutableKeywords
Signed-off-by: Babak K. Shandiz <babakks@github.com>
1 parent 1533d81 commit 56cdc36

3 files changed

Lines changed: 29 additions & 28 deletions

File tree

pkg/cmd/pr/shared/params.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func SearchQueryBuild(options FilterOptions, advancedIssueSearchSyntax bool) str
222222
Is: []string{is},
223223
Type: options.Entity,
224224
},
225-
KeywordsVerbatim: options.Search,
225+
ImmutableKeywords: options.Search,
226226
}
227227

228228
if !advancedIssueSearchSyntax {

pkg/search/query.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ type Query struct {
2121
// as needed. This is useful when the input can be supplied as a list of
2222
// search keywords.
2323
//
24-
// This field is mutually exclusive with KeywordsVerbatim.
24+
// This field is overridden by ImmutableKeywords.
2525
Keywords []string
26-
// KeywordsVerbatim holds the search keywords as a single string, and will
26+
27+
// ImmutableKeywords holds the search keywords as a single string, and will
2728
// be treated as is (e.g. no additional quoting). This is useful when the
2829
// input is meant to be taken verbatim from the user.
2930
//
30-
// This field is mutually exclusive with Keywords.
31-
KeywordsVerbatim string
31+
// This field takes precedence over Keywords.
32+
ImmutableKeywords string
3233

3334
Kind string
3435
Limit int
@@ -117,8 +118,8 @@ type Qualifiers struct {
117118
func (q Query) StandardSearchString() string {
118119
qualifiers := formatQualifiers(q.Qualifiers, nil)
119120
var keywords []string
120-
if q.KeywordsVerbatim != "" {
121-
keywords = []string{q.KeywordsVerbatim}
121+
if q.ImmutableKeywords != "" {
122+
keywords = []string{q.ImmutableKeywords}
122123
} else if ks := formatKeywords(q.Keywords); len(ks) > 0 {
123124
keywords = ks
124125
}
@@ -143,7 +144,7 @@ func (q Query) StandardSearchString() string {
143144
// The advanced syntax is documented at https://github.blog/changelog/2025-03-06-github-issues-projects-api-support-for-issues-advanced-search-and-more
144145
func (q Query) AdvancedIssueSearchString() string {
145146
qualifiers := strings.Join(formatQualifiers(q.Qualifiers, formatAdvancedIssueSearch), " ")
146-
keywords := q.KeywordsVerbatim
147+
keywords := q.ImmutableKeywords
147148
if keywords == "" {
148149
keywords = strings.Join(formatKeywords(q.Keywords), " ")
149150
}

pkg/search/query_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,29 @@ func TestStandardSearchString(t *testing.T) {
7575
out: `topic:"quote qualifier"`,
7676
},
7777
{
78-
name: "respects verbatim keywords",
78+
name: "respects immutable keywords",
7979
query: Query{
80-
KeywordsVerbatim: "verbatim keyword that should be left as is",
80+
ImmutableKeywords: "immutable keyword that should be left as is",
8181
},
82-
out: `verbatim keyword that should be left as is`,
82+
out: `immutable keyword that should be left as is`,
8383
},
8484
{
85-
name: "respects verbatim keywords, with qualifiers",
85+
name: "respects immutable keywords, with qualifiers",
8686
query: Query{
87-
KeywordsVerbatim: "verbatim keyword that should be left as is",
87+
ImmutableKeywords: "immutable keyword that should be left as is",
8888
Qualifiers: Qualifiers{
8989
Topic: []string{"quote qualifier"},
9090
},
9191
},
92-
out: `verbatim keyword that should be left as is topic:"quote qualifier"`,
92+
out: `immutable keyword that should be left as is topic:"quote qualifier"`,
9393
},
9494
{
95-
name: "prioritises verbatim keywords over keywords slice",
95+
name: "prioritises immutable keywords over keywords slice",
9696
query: Query{
97-
Keywords: []string{"foo", "bar"},
98-
KeywordsVerbatim: "verbatim keyword",
97+
Keywords: []string{"foo", "bar"},
98+
ImmutableKeywords: "immutable keyword",
9999
},
100-
out: `verbatim keyword`,
100+
out: `immutable keyword`,
101101
},
102102
}
103103
for _, tt := range tests {
@@ -141,29 +141,29 @@ func TestAdvancedIssueSearchString(t *testing.T) {
141141
out: `label:"quote qualifier"`,
142142
},
143143
{
144-
name: "respects verbatim keywords",
144+
name: "respects immutable keywords",
145145
query: Query{
146-
KeywordsVerbatim: "verbatim keyword that should be left as is",
146+
ImmutableKeywords: "immutable keyword that should be left as is",
147147
},
148-
out: `verbatim keyword that should be left as is`,
148+
out: `immutable keyword that should be left as is`,
149149
},
150150
{
151-
name: "respects verbatim keywords, with qualifiers",
151+
name: "respects immutable keywords, with qualifiers",
152152
query: Query{
153-
KeywordsVerbatim: "verbatim keyword that should be left as is",
153+
ImmutableKeywords: "immutable keyword that should be left as is",
154154
Qualifiers: Qualifiers{
155155
Topic: []string{"quote qualifier"},
156156
},
157157
},
158-
out: `( verbatim keyword that should be left as is ) topic:"quote qualifier"`,
158+
out: `( immutable keyword that should be left as is ) topic:"quote qualifier"`,
159159
},
160160
{
161-
name: "prioritises verbatim keywords over keywords slice",
161+
name: "prioritises immutable keywords over keywords slice",
162162
query: Query{
163-
Keywords: []string{"foo", "bar"},
164-
KeywordsVerbatim: "verbatim keyword",
163+
Keywords: []string{"foo", "bar"},
164+
ImmutableKeywords: "immutable keyword",
165165
},
166-
out: `verbatim keyword`,
166+
out: `immutable keyword`,
167167
},
168168
{
169169
name: "unused qualifiers should not appear in query",

0 commit comments

Comments
 (0)