MCPcopy Create free account
hub / github.com/gogs/gogs / GetRepositoryByRef

Function GetRepositoryByRef

internal/database/repo.go:1764–1777  ·  view source on GitHub ↗

GetRepositoryByRef returns a Repository specified by a GFM reference. See https://help.github.com/articles/writing-on-github#references for more information on the syntax.

(ref string)

Source from the content-addressed store, hash-verified

1762// GetRepositoryByRef returns a Repository specified by a GFM reference.
1763// See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
1764func GetRepositoryByRef(ref string) (*Repository, error) {
1765 n := strings.IndexByte(ref, byte('/'))
1766 if n < 2 {
1767 return nil, InvalidRepoReference{Ref: ref}
1768 }
1769
1770 userName, repoName := ref[:n], ref[n+1:]
1771 user, err := Handle.Users().GetByUsername(context.TODO(), userName)
1772 if err != nil {
1773 return nil, err
1774 }
1775
1776 return GetRepositoryByName(user.ID, repoName)
1777}
1778
1779// GetRepositoryByName returns the repository by given name under user if exists.
1780// Deprecated: Use Repos.GetByName instead.

Callers 1

GetIssueByRefFunction · 0.85

Calls 3

GetRepositoryByNameFunction · 0.85
GetByUsernameMethod · 0.80
UsersMethod · 0.80

Tested by

no test coverage detected