mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
Remove GetRepositoryByRef and add GetRepositoryByOwnerAndName (#3043)
* remove GetRepositoryByRef and add GetRepositoryByOwnerAndName * fix tests * fix tests bug * some improvements
This commit is contained in:
parent
674422b642
commit
35cc5b0402
7 changed files with 42 additions and 66 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue