dfgitutil

package
v0.30.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Overview

Package dfgitutil provides Dockerfile-specific utilities for git refs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FragmentFormat added in v0.26.0

func FragmentFormat(remote string, withSubdir bool) (string, bool)

FragmentFormat returns a simplified git URL in fragment format. If the URL cannot be parsed, the original string is returned with false.

Types

type GitRef

type GitRef struct {
	// Remote is the remote repository path.
	Remote string

	// ShortName is the directory name of the repo.
	// e.g., "bar" for "https://github.com/foo/bar.git"
	ShortName string

	// Ref is a commit hash, a tag, or branch name.
	// Ref is optional.
	Ref string

	// Checksum is a commit hash.
	Checksum string

	// SubDir is a directory path inside the repo.
	// SubDir is optional.
	SubDir string

	// IndistinguishableFromLocal is true for a ref that is indistinguishable from a local file path,
	// e.g., "github.com/foo/bar".
	//
	// Deprecated.
	// Instead, use a distinguishable form such as "https://github.com/foo/bar.git".
	//
	// The dockerfile frontend still accepts this form only for build contexts.
	IndistinguishableFromLocal bool

	// UnencryptedTCP is true for a ref that needs an unencrypted TCP connection,
	// e.g., "git://..." and "http://..." .
	//
	// Discouraged, although not deprecated.
	// Instead, consider using an encrypted TCP connection such as "git@github.com/foo/bar.git" or "https://github.com/foo/bar.git".
	UnencryptedTCP bool

	// KeepGitDir is true for URL that controls whether to keep the .git directory.
	KeepGitDir *bool

	// Submodules is true for URL that controls whether to fetch git submodules.
	Submodules *bool

	// MTime controls file modification time policy: "checkout" (default) or "commit".
	MTime string

	// FetchByCommit, when true, trusts Checksum as the commit and skips comparing
	// it against the remote ref. The commit is fetched directly and the ref name
	// (if any) is applied locally.
	FetchByCommit bool
}

GitRef represents a git ref.

Examples:

func ParseGitRef

func ParseGitRef(ref string) (*GitRef, bool, error)

ParseGitRef parses a git ref.

Jump to

Keyboard shortcuts

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