Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcfd7ef9

Browse files
authored
Correct lower-case issue state (#1567)
* Correct lower-case issue state* Uppercase orderBy and direction as well* Auto-correct invalid enum parameters
1 parent82c4930 commitcfd7ef9

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

‎pkg/github/issues.go‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,11 +1381,14 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
13811381
returnutils.NewToolResultError(err.Error()),nil,nil
13821382
}
13831383

1384-
// If the state has a value, cast into an array of strings
1384+
// Normalize and filter by state
1385+
state=strings.ToUpper(state)
13851386
varstates []githubv4.IssueState
1386-
ifstate!="" {
1387-
states=append(states,githubv4.IssueState(state))
1388-
}else {
1387+
1388+
switchstate {
1389+
case"OPEN","CLOSED":
1390+
states= []githubv4.IssueState{githubv4.IssueState(state)}
1391+
default:
13891392
states= []githubv4.IssueState{githubv4.IssueStateOpen,githubv4.IssueStateClosed}
13901393
}
13911394

@@ -1405,13 +1408,21 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun
14051408
returnutils.NewToolResultError(err.Error()),nil,nil
14061409
}
14071410

1408-
// These variables are required for the GraphQL query to be set by default
1409-
// If orderBy is empty, default to CREATED_AT
1410-
iforderBy=="" {
1411+
// Normalize and validate orderBy
1412+
orderBy=strings.ToUpper(orderBy)
1413+
switchorderBy {
1414+
case"CREATED_AT","UPDATED_AT","COMMENTS":
1415+
// Valid, keep as is
1416+
default:
14111417
orderBy="CREATED_AT"
14121418
}
1413-
// If direction is empty, default to DESC
1414-
ifdirection=="" {
1419+
1420+
// Normalize and validate direction
1421+
direction=strings.ToUpper(direction)
1422+
switchdirection {
1423+
case"ASC","DESC":
1424+
// Valid, keep as is
1425+
default:
14151426
direction="DESC"
14161427
}
14171428

‎pkg/github/issues_test.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,16 @@ func Test_ListIssues(t *testing.T) {
11831183
expectError:false,
11841184
expectedCount:2,
11851185
},
1186+
{
1187+
name:"filter by open state - lc",
1188+
reqParams:map[string]interface{}{
1189+
"owner":"owner",
1190+
"repo":"repo",
1191+
"state":"open",
1192+
},
1193+
expectError:false,
1194+
expectedCount:2,
1195+
},
11861196
{
11871197
name:"filter by closed state",
11881198
reqParams:map[string]interface{}{
@@ -1229,6 +1239,9 @@ func Test_ListIssues(t *testing.T) {
12291239
case"filter by open state":
12301240
matcher:=githubv4mock.NewQueryMatcher(qBasicNoLabels,varsOpenOnly,mockResponseOpenOnly)
12311241
httpClient=githubv4mock.NewMockedHTTPClient(matcher)
1242+
case"filter by open state - lc":
1243+
matcher:=githubv4mock.NewQueryMatcher(qBasicNoLabels,varsOpenOnly,mockResponseOpenOnly)
1244+
httpClient=githubv4mock.NewMockedHTTPClient(matcher)
12321245
case"filter by closed state":
12331246
matcher:=githubv4mock.NewQueryMatcher(qBasicNoLabels,varsClosedOnly,mockResponseClosedOnly)
12341247
httpClient=githubv4mock.NewMockedHTTPClient(matcher)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp