Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043)

* remove GetRepositoryByRef and add GetRepositoryByOwnerAndName

* fix tests

* fix tests bug

* some improvements
This commit is contained in:
Lunny Xiao 2017-12-02 15:34:39 +08:00 committed by GitHub
parent 674422b642
commit 35cc5b0402
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 66 deletions

View file

@ -964,7 +964,7 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
// GetIssueByRef returns an Issue specified by a GFM reference.
// See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
func GetIssueByRef(ref string) (*Issue, error) {
n := strings.IndexByte(ref, byte('#'))
n := strings.IndexByte(ref, '#')
if n == -1 {
return nil, errMissingIssueNumber
}
@ -974,7 +974,12 @@ func GetIssueByRef(ref string) (*Issue, error) {
return nil, errInvalidIssueNumber
}
repo, err := GetRepositoryByRef(ref[:n])
i := strings.IndexByte(ref[:n], '/')
if i < 2 {
return nil, ErrInvalidReference
}
repo, err := GetRepositoryByOwnerAndName(ref[:i], ref[i+1:n])
if err != nil {
return nil, err
}