Fix `hub pr list -h <BRANCH>` when owner isn't specified

Previously, when `:` wouldn't appear in the value for `head`, the GitHub
API would ignore the `head` parameter altogether. Now, ensure that
`<OWNER>:` syntax is always populated by adding the default from the
current repository.
This commit is contained in:
Mislav Marohnić 2018-06-07 11:37:01 +02:00
Родитель 6cc3b99ff3
Коммит 3e89bfba95
2 изменённых файлов: 21 добавлений и 3 удалений

Просмотреть файл

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strconv"
"strings"
"github.com/github/hub/github"
"github.com/github/hub/ui"
@ -32,8 +33,9 @@ pr checkout <PR-NUMBER> [<BRANCH>]
-s, --state <STATE>
Filter pull requests by <STATE> (default: "open").
-h, --head <BRANCH>
Show pull requests started from the specified head <BRANCH>.
-h, --head [<OWNER>:]<BRANCH>
Show pull requests started from the specified head <BRANCH>. The default
value for <OWNER> is taken from the current repository.
-b, --base <BRANCH>
Show pull requests based on the specified <BRANCH>.
@ -162,6 +164,10 @@ func listPulls(cmd *Command, args *Args) {
return
}
if flagPullRequestHead != "" && !strings.Contains(flagPullRequestHead, ":") {
flagPullRequestHead = fmt.Sprintf("%s:%s", project.Owner, flagPullRequestHead)
}
flagFilters := map[string]string{
"state": flagPullRequestState,
"head": flagPullRequestHead,

Просмотреть файл

@ -81,10 +81,22 @@ Feature: hub pr list
"""
get('/repos/github/hub/pulls') {
assert :base => "develop",
:head => "patch-1"
:head => "github:patch-1"
json []
}
"""
When I successfully run `hub pr list -b develop -h patch-1`
Then the output should contain exactly ""
Scenario: Filter by head with owner
Given the GitHub API server:
"""
get('/repos/github/hub/pulls') {
assert :head => "mislav:patch-1"
json []
}
"""
When I successfully run `hub pr list -h mislav:patch-1`
Then the output should contain exactly ""