diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-02 15:34:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-02 15:34:39 +0800 |
commit | 35cc5b0402d46d672e02bbe1ad15d1460077e8f4 (patch) | |
tree | 47723925eb89e286f328503ae30e77ca1eaaf021 /models/issue.go | |
parent | 674422b642452050a7185f10908a9e8a86604f24 (diff) | |
download | gitea-35cc5b0402d46d672e02bbe1ad15d1460077e8f4.tar.gz gitea-35cc5b0402d46d672e02bbe1ad15d1460077e8f4.zip |
Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043)
* remove GetRepositoryByRef and add GetRepositoryByOwnerAndName
* fix tests
* fix tests bug
* some improvements
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/models/issue.go b/models/issue.go index 17aef10553..00e0bf8027 100644 --- a/models/issue.go +++ b/models/issue.go @@ -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 } |