提交 b15d8de5 编写于 作者: M Mislav Marohnić

Ensure consistent sort direction when listing issues, PRs

The default direction when sorting by `created` date (the default) is
descending. However, the default on the API backend changes to ascending
when the sort key is something different than `created`:
https://developer.github.com/v3/pulls/#list-pull-requests

This ensures that the default `direction: "desc"` is always passed to
API queries, regardless of the sort key, unless `--sort-ascending` was used.

Ref. https://github.com/github/hub/issues/1815#issuecomment-433222344
上级 bd8042ec
......@@ -248,6 +248,8 @@ func listIssues(cmd *Command, args *Args) {
if flagIssueSortAscending {
filters["direction"] = "asc"
} else {
filters["direction"] = "desc"
}
if cmd.FlagPassed("since") {
......
......@@ -182,6 +182,8 @@ func listPulls(cmd *Command, args *Args) {
}
if flagPullRequestSortAscending {
filters["direction"] = "asc"
} else {
filters["direction"] = "desc"
}
pulls, err := gh.FetchPullRequests(project, filters, flagPullRequestLimit, nil)
......
......@@ -9,7 +9,7 @@ Feature: hub issue
get('/repos/github/hub/issues') {
assert :assignee => "Cornwe19",
:sort => nil,
:direction => nil
:direction => "desc"
json [
{ :number => 999,
......@@ -76,7 +76,7 @@ Feature: hub issue
get('/repos/github/hub/issues') {
assert :assignee => "Cornwe19",
:sort => nil,
:direction => nil
:direction => "desc"
json [
{ :number => 999,
......
......@@ -10,7 +10,7 @@ Feature: hub pr list
assert :per_page => "100",
:page => :no,
:sort => nil,
:direction => nil
:direction => "desc"
response.headers["Link"] = %(<https://api.github.com/repositories/12345?per_page=100&page=2>; rel="next")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册