gitremote

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gitremote provides general-purpose git remote URL utilities: parsing, resolving, and redacting remote URLs. It has no dependency on checkpoint, strategy, or settings packages.

Index

Constants

View Source
const (
	ProtocolSSH   = "ssh"
	ProtocolHTTPS = "https"
)

Variables

This section is empty.

Functions

func ExtractOwnerFromRemoteURL

func ExtractOwnerFromRemoteURL(rawURL string) string

ExtractOwnerFromRemoteURL extracts the owner component from a git remote URL. Returns an empty string if the URL cannot be parsed.

func GetRemoteURL

func GetRemoteURL(ctx context.Context, remoteName string) (string, error)

GetRemoteURL returns the URL configured for the named git remote.

func RedactURL

func RedactURL(rawURL string) string

RedactURL removes credentials and query parameters from a URL for safe logging. SCP-style SSH URLs (e.g., git@github.com:org/repo.git) are returned as-is since they contain no embedded credentials.

func ResolveRemoteRepo

func ResolveRemoteRepo(ctx context.Context, remoteName string) (host, owner, repo string, err error)

ResolveRemoteRepo returns the host, owner, and repo name for the given git remote. It parses the remote URL (SSH or HTTPS) and extracts the components. For example, git@github.com:org/my-repo.git returns ("github.com", "org", "my-repo").

Types

type Info

type Info struct {
	Protocol string
	Host     string
	Port     string
	Owner    string
	Repo     string
}

Info holds the parsed components of a git remote URL. Host is the hostname only (never includes a port). Port is empty unless the source URL specified an explicit non-default port. Callers that need the combined "host[:port]" form should use HostPort.

func ParseURL

func ParseURL(rawURL string) (*Info, error)

ParseURL parses a git remote URL (SSH SCP-style or HTTPS) into its components.

func (*Info) HostPort

func (i *Info) HostPort() string

HostPort returns Host, or "Host:Port" when Port is non-empty.

Jump to

Keyboard shortcuts

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