git

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package git provides functions for determining changes in a git repository.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrGitStatusUnclean reported when the git status reports uncommitted
	// changes.
	ErrGitStatusUnclean = errors.New("git working directory is not clean")
)

Functions

func AssertGitStatusClean

func AssertGitStatusClean(ctx context.Context, gitExe string) error

AssertGitStatusClean returns an error if the git working directory has uncommitted changes.

func CheckRemoteURL

func CheckRemoteURL(ctx context.Context, gitExe, remote string) error

CheckRemoteURL checks that the git remote URL exists.

func CheckVersion

func CheckVersion(ctx context.Context, gitExe string) error

CheckVersion checks that the git version command can run.

func Checkout added in v0.8.1

func Checkout(ctx context.Context, gitExe, revision string) error

Checkout checks out the given revision. If revision is a commit rather than a branch, this will leave the repository with a detached head. If revision is the name of a valid path, that file is checked out instead. (Git does not provide a way of differentiation between these.)

func FilesChangedSince

func FilesChangedSince(ctx context.Context, gitExe, ref string, ignoredChanges []string) ([]string, error)

FilesChangedSince returns the files changed since the given git ref.

func FindCommitsForPath

func FindCommitsForPath(ctx context.Context, gitExe, path string) ([]string, error)

FindCommitsForPath returns the full hashes of all commits affecting the given path. The commits are returned in normal log order, i.e. latest commit first.

func GetCommitHash added in v0.8.1

func GetCommitHash(ctx context.Context, gitExe, revision string) (string, error)

GetCommitHash returns the commit hash pointed at by the given revision, which could be a tag name, a branch name, a relative revision (e.g. "HEAD~").

func GetLastTag

func GetLastTag(ctx context.Context, gitExe, remote, branch string) (string, error)

GetLastTag returns the last git tag for the given release configuration.

func IsNewFile

func IsNewFile(ctx context.Context, gitExe, ref, name string) bool

IsNewFile returns true if the given file is new since the given git ref.

func MatchesBranchPoint

func MatchesBranchPoint(ctx context.Context, gitExe, remote, branch string) error

MatchesBranchPoint returns an error if the local repository has unpushed changes.

func ShowFileAtRemoteBranch

func ShowFileAtRemoteBranch(ctx context.Context, gitExe, remote, branch, path string) (string, error)

ShowFileAtRemoteBranch shows the contents of the file found at the given path on the given remote/branch.

func ShowFileAtRevision

func ShowFileAtRevision(ctx context.Context, gitExe, revision, path string) (string, error)

ShowFileAtRevision shows the contents of the file found at the given path at the given revision (which can be a tag, a commit, a remote/branch etc).

func Tag added in v0.8.1

func Tag(ctx context.Context, gitExe, tagName, revision string) error

Tag creates the given tag name pointing at the given revision. The revision is often a commit hash, but can be a relative revision (e.g. "HEAD~").

Types

This section is empty.

Jump to

Keyboard shortcuts

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