gitref

package
v1.0.0-beta.12 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package gitref holds the pure, dependency-light logic for classifying and parsing module reference strings (local path vs git, scheme detection, git repo-root resolution). It deliberately avoids importing the engine "core" package (and the Linux-only engine code that comes with it) so that the CLI can reuse this logic and still cross-compile for darwin/windows.

The richer, dagql-aware wrappers (ModuleSourceKind enum, ParsedGitRefString with its GitRef resolution) live in package core and delegate here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayRef

func DisplayRef(ref string) string

DisplayRef keeps the user's spelling while removing URL credentials. HTTP usernames can themselves be tokens. SSH usernames are part of the address.

func GitURLRefString

func GitURLRefString(cloneRef, sourceRootSubpath, version string) string

GitURLRefString builds the explicit Git URL form protocol://repo#ref[:subpath].

func LooksRemote

func LooksRemote(ref string) bool

LooksRemote distinguishes a host/path reference from a missing local path. Callers must check for an existing local directory before using this hint.

func RefString

func RefString(cloneRef, sourceRootSubpath, version string) string

RefString builds a module ref string from a clone ref, an optional source root subpath and an optional version.

Types

type EndpointError

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

EndpointError indicates the ref could not be parsed/resolved as a git endpoint (callers may choose to fall back to treating it as a local path).

func (EndpointError) Unwrap

func (e EndpointError) Unwrap() error

type Kind

type Kind int

Kind is a quick classification of a module ref string.

const (
	// KindUnknown means the kind could not be determined by a fast heuristic
	// and further inspection (e.g. statting the filesystem) is required.
	KindUnknown Kind = iota
	KindLocal
	KindGit
)

func FastKindCheck

func FastKindCheck(refString, refPin string) Kind

FastKindCheck performs a quick heuristic check to determine whether a module ref string refers to a local path or a git source. Returns KindUnknown if the kind cannot be determined without further inspection.

type Parsed

type Parsed struct {
	ModPath string

	ModVersion string
	HasVersion bool
	Selector   SelectorType

	RepoRoot       *vcs.RepoRoot
	RepoRootSubdir string

	Scheme SchemeType

	SourceUser     string
	CloneUser      string
	SourceCloneRef string // original user-provided username
	CloneRef       string // resolved username
}

Parsed holds the parsed components of a git ref string.

func Parse

func Parse(ctx context.Context, refString string) (_ Parsed, rerr error)

Parse parses a git ref string into its components.

type SchemeType

type SchemeType int

SchemeType is the URL scheme of a git ref string.

const (
	NoScheme SchemeType = iota
	SchemeHTTP
	SchemeHTTPS
	SchemeGit
	SchemeSSH
	SchemeSCPLike
)

func Scheme

func Scheme(refString string) SchemeType

Scheme classifies the transport scheme of a ref string, including SCP-like ("git@host:path") refs. It is a pure, network-free helper so callers can decide eligibility (e.g. for the https-only dagger-get redirect probe) without importing the engine.

func (SchemeType) IsSSH

func (s SchemeType) IsSSH() bool

func (SchemeType) Prefix

func (s SchemeType) Prefix() string

type SelectorType

type SelectorType int

SelectorType describes how a ref selects a revision and source subpath.

const (
	NoSelector SelectorType = iota
	// ModuleVersionSelector is the Go-like import path form: path/to/module@ref.
	// SemVer-shaped refs in this form may be resolved as version queries.
	ModuleVersionSelector
	// GitRefSelector is the Git URL form: protocol://repo#ref[:subpath]. Its ref
	// is always resolved literally, even when it looks like a SemVer query.
	GitRefSelector
)

Jump to

Keyboard shortcuts

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