diff --git a/api/queries_issue.go b/api/queries_issue.go index 56a04edd9..3da827ae1 100644 --- a/api/queries_issue.go +++ b/api/queries_issue.go @@ -198,7 +198,7 @@ func IssueStatus(client *Client, repo ghrepo.Interface, currentUsername string) return &payload, nil } -func IssueList(client *Client, repo ghrepo.Interface, state string, labels []string, assigneeString string, limit int, authorString string) (*IssuesAndTotalCount, error) { +func IssueList(client *Client, repo ghrepo.Interface, state string, labels []string, assigneeString string, limit int, authorString string, mentionedString string) (*IssuesAndTotalCount, error) { var states []string switch state { case "open", "": @@ -215,7 +215,7 @@ func IssueList(client *Client, repo ghrepo.Interface, state string, labels []str query($owner: String!, $repo: String!, $limit: Int, $endCursor: String, $states: [IssueState!] = OPEN, $labels: [String!], $assignee: String, $author: String) { repository(owner: $owner, name: $repo) { hasIssuesEnabled - issues(first: $limit, after: $endCursor, orderBy: {field: CREATED_AT, direction: DESC}, states: $states, labels: $labels, filterBy: {assignee: $assignee, createdBy: $author}) { + issues(first: $limit, after: $endCursor, orderBy: {field: CREATED_AT, direction: DESC}, states: $states, labels: $labels, filterBy: {assignee: $assignee, createdBy: $author, mentioned: $mentioned}) { totalCount nodes { ...issue @@ -243,6 +243,9 @@ func IssueList(client *Client, repo ghrepo.Interface, state string, labels []str if authorString != "" { variables["author"] = authorString } + if mentionedString != "" { + variables["mentioned"] = mentionedString + } var response struct { Repository struct { diff --git a/api/queries_issue_test.go b/api/queries_issue_test.go index ffe4aaad1..4eff67804 100644 --- a/api/queries_issue_test.go +++ b/api/queries_issue_test.go @@ -40,7 +40,7 @@ func TestIssueList(t *testing.T) { `)) repo, _ := ghrepo.FromFullName("OWNER/REPO") - _, err := IssueList(client, repo, "open", []string{}, "", 251, "") + _, err := IssueList(client, repo, "open", []string{}, "", 251, "", "") if err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/command/issue.go b/command/issue.go index 526d02871..85e0696a6 100644 --- a/command/issue.go +++ b/command/issue.go @@ -41,6 +41,7 @@ func init() { issueListCmd.Flags().StringP("state", "s", "open", "Filter by state: {open|closed|all}") issueListCmd.Flags().IntP("limit", "L", 30, "Maximum number of issues to fetch") issueListCmd.Flags().StringP("author", "A", "", "Filter by author") + issueListCmd.Flags().StringP("mentioned", "", "", "Filter by mention") issueCmd.AddCommand(issueViewCmd) issueViewCmd.Flags().BoolP("web", "w", false, "Open an issue in the browser") @@ -141,7 +142,12 @@ func issueList(cmd *cobra.Command, args []string) error { return err } - listResult, err := api.IssueList(apiClient, baseRepo, state, labels, assignee, limit, author) + mentioned, err := cmd.Flags().GetString("mentioned") + if err != nil { + return err + } + + listResult, err := api.IssueList(apiClient, baseRepo, state, labels, assignee, limit, author, mentioned) if err != nil { return err } diff --git a/command/issue_test.go b/command/issue_test.go index 418de25d3..ce91c98e2 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -153,7 +153,7 @@ func TestIssueList_withFlags(t *testing.T) { } } } `)) - output, err := RunCommand("issue list -a probablyCher -l web,bug -s open -A foo") + output, err := RunCommand("issue list -a probablyCher -l web,bug -s open -A foo --mentioned me") if err != nil { t.Errorf("error running command `issue list`: %v", err) } @@ -167,10 +167,11 @@ No issues match your search in OWNER/REPO bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body) reqBody := struct { Variables struct { - Assignee string - Labels []string - States []string - Author string + Assignee string + Labels []string + States []string + Author string + Mentioned string } }{} _ = json.Unmarshal(bodyBytes, &reqBody) @@ -179,6 +180,7 @@ No issues match your search in OWNER/REPO eq(t, reqBody.Variables.Labels, []string{"web", "bug"}) eq(t, reqBody.Variables.States, []string{"OPEN"}) eq(t, reqBody.Variables.Author, "foo") + eq(t, reqBody.Variables.Mentioned, "me") } func TestIssueList_withInvalidLimitFlag(t *testing.T) {