From 210d9dff2077816506b6efcce0db8bf5514dd6e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 25 Mar 2021 13:44:07 +0100 Subject: [PATCH] Remove implicit `sort:created-desc` sort clause for `pr list` This is the default sort mode for issues, so it's not needed to explicitly set it. Furthermore, the user can specify their own sort mode through the `--search` option. --- pkg/cmd/pr/list/http.go | 1 - pkg/cmd/pr/list/http_test.go | 4 ++-- pkg/cmd/pr/list/list_test.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/pr/list/http.go b/pkg/cmd/pr/list/http.go index 8936600bc..e80ffcd90 100644 --- a/pkg/cmd/pr/list/http.go +++ b/pkg/cmd/pr/list/http.go @@ -172,7 +172,6 @@ func searchPullRequests(httpClient *http.Client, repo ghrepo.Interface, filters q.SetType(githubsearch.PullRequest) q.InRepository(ghrepo.FullName(repo)) q.AddQuery(filters.Search) - q.SortBy(githubsearch.CreatedAt, githubsearch.Desc) switch filters.State { case "open": diff --git a/pkg/cmd/pr/list/http_test.go b/pkg/cmd/pr/list/http_test.go index 6ac4e2cfa..9a82b5c16 100644 --- a/pkg/cmd/pr/list/http_test.go +++ b/pkg/cmd/pr/list/http_test.go @@ -116,7 +116,7 @@ func Test_listPullRequests(t *testing.T) { httpmock.GraphQL(`query PullRequestSearch\b`), httpmock.GraphQLQuery(`{"data":{}}`, func(query string, vars map[string]interface{}) { want := map[string]interface{}{ - "q": "repo:OWNER/REPO is:pr is:open author:monalisa sort:created-desc", + "q": "repo:OWNER/REPO is:pr is:open author:monalisa", "limit": float64(30), } if !reflect.DeepEqual(vars, want) { @@ -140,7 +140,7 @@ func Test_listPullRequests(t *testing.T) { httpmock.GraphQL(`query PullRequestSearch\b`), httpmock.GraphQLQuery(`{"data":{}}`, func(query string, vars map[string]interface{}) { want := map[string]interface{}{ - "q": "repo:OWNER/REPO is:pr is:open sort:created-desc one world in:title", + "q": "repo:OWNER/REPO is:pr is:open one world in:title", "limit": float64(30), } if !reflect.DeepEqual(vars, want) { diff --git a/pkg/cmd/pr/list/list_test.go b/pkg/cmd/pr/list/list_test.go index 28be3aee2..73b9ff2b6 100644 --- a/pkg/cmd/pr/list/list_test.go +++ b/pkg/cmd/pr/list/list_test.go @@ -165,7 +165,7 @@ func TestPRList_filteringAssignee(t *testing.T) { http.Register( httpmock.GraphQL(`query PullRequestSearch\b`), httpmock.GraphQLQuery(`{}`, func(_ string, params map[string]interface{}) { - assert.Equal(t, `repo:OWNER/REPO is:pr is:merged assignee:hubot label:"needs tests" base:develop sort:created-desc`, params["q"].(string)) + assert.Equal(t, `repo:OWNER/REPO is:pr is:merged assignee:hubot label:"needs tests" base:develop`, params["q"].(string)) })) _, err := runCommand(http, true, `-s merged -l "needs tests" -a hubot -B develop`)