git

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package git allows to interact with Git.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentBranchName deprecated

func GetCurrentBranchName(t testing.TestingT) string

GetCurrentBranchName retrieves the current branch name or an empty string in case of detached state. Fails the test if an error occurs.

Deprecated: Use GetCurrentBranchNameContext instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

func GetCurrentBranchNameContext added in v1.0.0

func GetCurrentBranchNameContext(t testing.TestingT, ctx context.Context, dir string) string

GetCurrentBranchNameContext retrieves the current branch name or an empty string in case of detached state. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used. Fails the test if an error occurs.

func GetCurrentBranchNameContextE added in v1.0.0

func GetCurrentBranchNameContextE(t testing.TestingT, ctx context.Context, dir string) (string, error)

GetCurrentBranchNameContextE retrieves the current branch name or an empty string in case of detached state. Uses git branch --show-current, which was introduced in git v2.22. Falls back to git rev-parse for older versions. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used.

func GetCurrentBranchNameE deprecated

func GetCurrentBranchNameE(t testing.TestingT) (string, error)

GetCurrentBranchNameE retrieves the current branch name or an empty string in case of detached state. Uses git branch --show-current, which was introduced in git v2.22. Falls back to git rev-parse for older versions.

Deprecated: Use GetCurrentBranchNameContextE instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

func GetCurrentBranchNameOldContextE added in v1.0.0

func GetCurrentBranchNameOldContextE(t testing.TestingT, ctx context.Context, dir string) (string, error)

GetCurrentBranchNameOldContextE retrieves the current branch name or an empty string in case of detached state using git rev-parse --abbrev-ref HEAD. This is a fallback for git versions older than v2.22 that lack git branch --show-current. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used.

func GetCurrentBranchNameOldE deprecated added in v0.32.15

func GetCurrentBranchNameOldE(t testing.TestingT) (string, error)

GetCurrentBranchNameOldE retrieves the current branch name or an empty string in case of detached state using git rev-parse --abbrev-ref HEAD.

Deprecated: Use GetCurrentBranchNameOldContextE instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

func GetCurrentGitRef deprecated added in v0.29.0

func GetCurrentGitRef(t testing.TestingT) string

GetCurrentGitRef retrieves the current branch name, lightweight (non-annotated) tag, or exact tag value if the tag points to the current commit. Fails the test if an error occurs.

Deprecated: Use GetCurrentGitRefContext instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

func GetCurrentGitRefContext added in v1.0.0

func GetCurrentGitRefContext(t testing.TestingT, ctx context.Context, dir string) string

GetCurrentGitRefContext retrieves the current branch name, lightweight (non-annotated) tag, or exact tag value if the tag points to the current commit. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used. Fails the test if an error occurs.

func GetCurrentGitRefContextE added in v1.0.0

func GetCurrentGitRefContextE(t testing.TestingT, ctx context.Context, dir string) (string, error)

GetCurrentGitRefContextE retrieves the current branch name, lightweight (non-annotated) tag, or exact tag value if the tag points to the current commit. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used.

func GetCurrentGitRefE deprecated added in v0.29.0

func GetCurrentGitRefE(t testing.TestingT) (string, error)

GetCurrentGitRefE retrieves the current branch name, lightweight (non-annotated) tag, or exact tag value if the tag points to the current commit.

Deprecated: Use GetCurrentGitRefContextE instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

func GetRepoRoot deprecated added in v0.40.6

func GetRepoRoot(t testing.TestingT) string

GetRepoRoot retrieves the path to the root directory of the repo. Fails the test if there is an error.

Deprecated: Use GetRepoRootContext instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

func GetRepoRootContext added in v1.0.0

func GetRepoRootContext(t testing.TestingT, ctx context.Context, dir string) string

GetRepoRootContext retrieves the path to the root directory of the repo. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used. Fails the test if there is an error.

func GetRepoRootContextE added in v1.0.0

func GetRepoRootContextE(t testing.TestingT, ctx context.Context, dir string) (string, error)

GetRepoRootContextE retrieves the path to the root directory of the repo. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used.

func GetRepoRootE deprecated added in v0.40.6

func GetRepoRootE(t testing.TestingT) (string, error)

GetRepoRootE retrieves the path to the root directory of the repo.

Deprecated: Use GetRepoRootContextE instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

func GetRepoRootForDir deprecated added in v0.46.10

func GetRepoRootForDir(t testing.TestingT, dir string) string

GetRepoRootForDir retrieves the path to the root directory of the repo in which dir resides. Fails the test if there is an error.

Deprecated: Use GetRepoRootForDirContext instead, which supports context cancellation.

func GetRepoRootForDirContext added in v1.0.0

func GetRepoRootForDirContext(t testing.TestingT, ctx context.Context, dir string) string

GetRepoRootForDirContext retrieves the path to the root directory of the repo in which dir resides. Fails the test if there is an error.

func GetRepoRootForDirContextE added in v1.0.0

func GetRepoRootForDirContextE(t testing.TestingT, ctx context.Context, dir string) (string, error)

GetRepoRootForDirContextE retrieves the path to the root directory of the repo in which dir resides.

func GetRepoRootForDirE deprecated added in v0.46.10

func GetRepoRootForDirE(t testing.TestingT, dir string) (string, error)

GetRepoRootForDirE retrieves the path to the root directory of the repo in which dir resides.

Deprecated: Use GetRepoRootForDirContextE instead, which supports context cancellation.

func GetTagContextE added in v1.0.0

func GetTagContextE(t testing.TestingT, ctx context.Context, dir string) (string, error)

GetTagContextE retrieves the lightweight (non-annotated) tag or exact tag value if the tag points to the current commit. The dir parameter specifies the working directory for the git command; if empty, the process working directory is used.

func GetTagE deprecated added in v0.29.0

func GetTagE(t testing.TestingT) (string, error)

GetTagE retrieves the lightweight (non-annotated) tag or exact tag value if the tag points to the current commit.

Deprecated: Use GetTagContextE instead, which supports context cancellation and accepts an explicit working directory rather than relying on the process working directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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