gitremote

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitremote reads and switches a checkout's GitHub origin between the three transport modes: profile (git@github-<profile>:owner/repo.git), ssh (git@github.com:owner/repo.git) and https (https://github.com/owner/repo.git).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URLFor

func URLFor(m *manifest.Manifest, mode, owner, repo, profile string) (string, error)

URLFor builds the origin URL for owner/repo in mode. Profile mode needs a profile with a github.com host; ssh mode needs defaults.git.profile, whose key `Host github.com` uses.

Types

type Change

type Change struct {
	Dir, From, To string
	Applied       bool
	Skipped       string // why nothing changed; empty when it changed or would
}

Change is what `use` did, or would do, to one checkout.

func Use

func Use(g Git, m *manifest.Manifest, dir, mode, profile string, dryRun bool) (Change, error)

Use points dir's origin at mode. The new URL is proven with ls-remote before origin is rewritten, so a checkout never ends up with a remote it cannot authenticate to.

type Exec

type Exec struct{}

Exec is Git through the git binary.

func (Exec) LsRemote

func (e Exec) LsRemote(dir, url string) error

func (Exec) Origin

func (e Exec) Origin(dir string) (string, error)

func (Exec) SetOrigin

func (e Exec) SetOrigin(dir, url string) error

type Git

type Git interface {
	Origin(dir string) (string, error)
	LsRemote(dir, url string) error
	SetOrigin(dir, url string) error
}

Git is the slice of git this package needs, so tests can stand in for the network.

type Remote

type Remote struct {
	URL     string
	Mode    string // profile, ssh or https
	Owner   string
	Repo    string
	Profile string // profile mode: the profile whose alias it uses
}

Remote is a parsed GitHub origin.

func Parse

func Parse(m *manifest.Manifest, url string) (Remote, bool)

Parse recognises a GitHub origin. ok is false for anything else, which callers leave alone.

Jump to

Keyboard shortcuts

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