remote

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package remote turns a git remote URL into the pieces a forge call needs.

Index

Constants

View Source
const DefaultName = "origin"

DefaultName is the remote a project pushes to unless told otherwise.

Variables

View Source
var ErrForgeMismatch = errors.New("remote: forge mismatch")

ErrForgeMismatch reports a forge named for a host that is known to be a different one. The host is the stronger evidence, and letting the name win would send one forge's token to another's client.

View Source
var ErrNotARepository = errors.New("remote: not a repository URL")

ErrNotARepository reports a remote that cannot be read as owner/repo on a host.

Functions

This section is empty.

Types

type Remote

type Remote struct {
	// Host is the forge's hostname, without scheme, port or credentials.
	Host string

	// Owner is everything before the final path element. On this estate that
	// is frequently a nested group such as "phpboyscout/go", not a single
	// name.
	Owner string

	Repo string

	// Forge names the URL conventions, and is EMPTY when the host is not
	// recognised. A self-hosted instance cannot be identified by hostname, and
	// guessing would point every link in the changelog somewhere that does not
	// exist.
	Forge render.Forge

	// WebURL is the project's browsable URL, with any credentials removed.
	WebURL string
}

Remote is a parsed git remote.

func FromRepository

func FromRepository(path, name string) (Remote, error)

FromRepository reads the named remote out of the repository at path and parses it.

EnableDotGitCommonDir matters here for the same reason it does when reading history: in a linked worktree .git is a FILE pointing elsewhere, and without following it the repository opens and reports no remotes at all.

func Parse

func Parse(raw string) (Remote, error)

Parse reads a git remote URL in any of the forms git accepts.

func (Remote) Named added in v0.5.0

func (r Remote) Named(name render.Forge) (Remote, error)

Named sets the forge for a host that did not reveal one (spec 0009 D3).

An empty name changes nothing. A name that agrees with what the host said changes nothing. A name that disagrees is refused rather than honoured.

Jump to

Keyboard shortcuts

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