git

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Overview

Package git allows to interact with Git.

Deprecated: The git package is scheduled for removal in Terratest v2. Each helper here wraps a single git command (for example, git rev-parse or git describe); call git directly with os/exec instead. There is no public replacement; the package is being dropped.

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "branch", "--show-current").Output() (empty when detached).

func GetCurrentBranchNameContext deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "branch", "--show-current") with cmd.Dir = dir, then .Output().

func GetCurrentBranchNameContextE deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "branch", "--show-current") with cmd.Dir = dir, then .Output().

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "branch", "--show-current").Output() (empty when detached).

func GetCurrentBranchNameOldContextE deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "rev-parse", "--abbrev-ref", "HEAD") with cmd.Dir = dir, then .Output().

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD").Output() (prints "HEAD" when detached; map it to "").

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: scheduled for removal in Terratest v2. Shell out to git directly: try git branch --show-current, then git describe --tags when detached.

func GetCurrentGitRefContext deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly: try git branch --show-current, then git describe --tags when detached (set cmd.Dir = dir).

func GetCurrentGitRefContextE deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly: try git branch --show-current, then git describe --tags when detached (set cmd.Dir = dir).

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: scheduled for removal in Terratest v2. Shell out to git directly: try git branch --show-current, then git describe --tags when detached.

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "rev-parse", "--show-toplevel").Output().

func GetRepoRootContext deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "rev-parse", "--show-toplevel") with cmd.Dir = dir, then .Output().

func GetRepoRootContextE deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "rev-parse", "--show-toplevel") with cmd.Dir = dir, then .Output().

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "rev-parse", "--show-toplevel").Output().

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "rev-parse", "--show-toplevel") with cmd.Dir = dir, then .Output().

func GetRepoRootForDirContext deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "rev-parse", "--show-toplevel") with cmd.Dir = dir, then .Output().

func GetRepoRootForDirContextE deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "rev-parse", "--show-toplevel") with cmd.Dir = dir, then .Output().

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "rev-parse", "--show-toplevel") with cmd.Dir = dir, then .Output().

func GetTagContextE deprecated 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.

Deprecated: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.CommandContext(ctx, "git", "describe", "--tags") with cmd.Dir = dir, then .Output().

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: scheduled for removal in Terratest v2. Shell out to git directly, e.g. exec.Command("git", "describe", "--tags").Output().

Types

This section is empty.

Jump to

Keyboard shortcuts

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