giturl

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCloneURL

func BuildCloneURL(arg string, currentUser string) (*url.URL, error)

BuildCloneURL builds a clone URL from the given repository argument

func ExtractOwnerRepo

func ExtractOwnerRepo(u *url.URL) (owner, repo string, err error)

ExtractOwnerRepo extracts owner and repo name from a URL

func IsURL

func IsURL(u string) bool

IsURL checks if the given string is a git URL

func Parse

func Parse(rawURL string) (*url.URL, error)

Parse normalizes git remote urls, including scp-like syntax (git@github.com:owner/repo)

func Simplify

func Simplify(u *url.URL) *url.URL

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

type Repository struct {
	Owner string
	Name  string
	Host  string
}

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:

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL