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)
| 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. |
| 1764 | func 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. |
no test coverage detected