Help us shape the future of Go! Take the 2026 Go Developer Survey

gitremote

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gitremote lists the refs of repositories on github.com with `git ls-remote`, for the resolution of actions (ports.GitRemote). It sends no credentials, never prompts, and bounds the time and the output of git.

Index

Constants

View Source
const (
	// DefaultTimeout is how long ListRefs may take in all, its attempts
	// included. It is below the 30 s the runner gives a call.
	DefaultTimeout = 20 * time.Second
	// DefaultMaxOutput is the most bytes of ls-remote output read: a repository
	// with 100,000 tags lists about 8 MB. More is refused as unavailable.
	DefaultMaxOutput = 16 << 20
	// DefaultBaseURL is where the repositories are.
	DefaultBaseURL = "https://github.com"
)

Defaults of the bounds.

Variables

This section is empty.

Functions

func ProxyEnv

func ProxyEnv(get func(string) string) []string

ProxyEnv picks the proxy variables from an environment lookup (os.Getenv), for Config.Proxy. Empty ones are left out.

Types

type Config

type Config struct {
	// Bin is the git executable. Required.
	Bin string
	// Path is the PATH given to git, which it uses to find its helpers.
	Path string
	// Home is the HOME of git; it should be an empty directory the process
	// owns, so that no user configuration or credential is read.
	Home string
	// BaseURL, Timeout and MaxOutput default to the constants above; tests
	// replace them.
	BaseURL   string
	Timeout   time.Duration
	MaxOutput int
	// AllowedProtocols is GIT_ALLOW_PROTOCOL: "https" by default.
	AllowedProtocols string
	// Proxy is the proxy environment forwarded to git, as NAME=value pairs: see
	// ProxyEnv. Nothing else of the environment of ermite reaches git.
	Proxy []string
}

Config configures a Remote.

type Remote

type Remote struct {
	// contains filtered or unexported fields
}

Remote implements ports.GitRemote over the git binary.

func New

func New(cfg Config) *Remote

New builds a Remote.

func (*Remote) ListRefs

func (r *Remote) ListRefs(ctx context.Context, owner, repo string) ([]ports.RemoteRef, error)

ListRefs lists the branches and tags of owner/repo, with the peeled commit of the annotated tags. Timeout bounds the whole call, attempts and clean-up included: the time to clean up after an attempt (kill, WaitDelay) is reserved before it runs, and a ls-remote that timed out is run once more with what is left, at most half. The cancellation of ctx is returned as it is, not retried.

Source Files

  • gitremote.go
  • run_linux.go

Jump to

Keyboard shortcuts

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