gitremote

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package gitremote parses git remote URLs into their owner / repo / host components. MVP supports GitHub hosts only; other hosts return ok=false.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeadSHA added in v0.5.1

func HeadSHA(dir string) (string, error)

HeadSHA returns the 40-char hex SHA of HEAD for the git repository at dir. It returns an error when dir is not a git repository, has no commits yet, or any other `git rev-parse HEAD` failure occurs. Callers that need an always-succeed path (e.g. envelope auto-fill) should substitute their own fallback value on error rather than propagating it.

func OriginURL

func OriginURL(dir string) (string, error)

OriginURL returns the URL of the "origin" remote for the git repository at dir. Returns an error if dir is not a git repo or has no origin remote.

Types

type Remote

type Remote struct {
	Owner string
	Repo  string
	Host  string // e.g. "github.com"
}

Remote is a parsed git remote URL.

func Parse

func Parse(url string) (Remote, bool)

Parse extracts the owner/repo/host from a git remote URL. It returns (Remote, true) only for GitHub hosts in MVP; any other host (GitLab, Bitbucket, self-hosted) yields (_, false) so callers can gracefully skip rather than emit broken links.

Jump to

Keyboard shortcuts

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