Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCloneURL ¶
BuildCloneURL builds a clone URL from the given repository argument
func ExtractOwnerRepo ¶
ExtractOwnerRepo extracts owner and repo name from a URL
func Parse ¶
Parse normalizes git remote urls, including scp-like syntax (git@github.com:owner/repo)
func Simplify ¶
Simplify strips given URL of extra parts like extra path segments (i.e., anything beyond `/owner/repo`), query strings, or fragments.
This allows cloning from:
- (Tree) github.com/owner/repo/blob/main/foo/bar
- (Deep-link to line) github.com/owner/repo/blob/main/foo/bar#L168
- (Issue/PR comment) github.com/owner/repo/pull/999#issue-9999999999
- (Commit history) github.com/owner/repo/commits/main/?author=foo
Types ¶
type Repository ¶
Repository represents a Git repository with owner, name, and host
func ParseRepository ¶
func ParseRepository(arg string, currentUser string) (*Repository, error)
ParseRepository parses a repository string into a Repository struct. Supports multiple formats:
- "repo" (requires currentUser to resolve to currentUser/repo)
- "owner/repo"
- "https://github.com/owner/repo"
- "https://github.com/owner/repo/blob/main/file.go#L10"
- "git@github.com:owner/repo.git"
- "ssh://git@github.com/owner/repo.git"
func (*Repository) CloneURL ¶
func (r *Repository) CloneURL(protocol string) string
CloneURL returns the clone URL for the repository using the specified protocol
func (*Repository) FullName ¶
func (r *Repository) FullName() string
FullName returns the "owner/repo" string