git

package
v0.10.0-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checkout added in v0.9.2

func Checkout(ctx context.Context, version, workspaceDir string) error

Checkout checks out the provided version (branch, tag, or SHA) from the already-cloned given git workspace. It uses the git CLI already installed on the system.

If the given version is both a valid branch name and tag name, then we'll do what "git checkout" does in that case, and check out the branch.

If the version does not exist as a branch, tag, or SHA in this repo, then *NoSuchVersionError will be returned.

func Clone

func Clone(ctx context.Context, remote, outDir string) error

Clone checks out the given repo. It uses the git CLI already installed on the system.

"remote" may be any format accepted by git, such as https://github.com/abcxyz/abc.git or git@github.com:abcxyz/abc.git .

func CurrentSHA added in v0.5.0

func CurrentSHA(ctx context.Context, dir string) (string, error)

CurrentSHA returns the full SHA of the current HEAD in the given git workspace.

func HeadTags added in v0.5.0

func HeadTags(ctx context.Context, dir string) ([]string, error)

HeadTags looks at a local git workspace and returns the names of all tags that point to the current HEAD commit. If there are no such tags, returns empty slice, this is not an error.

func IsClean added in v0.5.0

func IsClean(ctx context.Context, dir string) (bool, error)

IsClean returns false if the given git workspace has any uncommitted changes, and otherwise returns true. Returns error if dir is not in a git workspace.

func LocalTags added in v0.9.2

func LocalTags(ctx context.Context, tmpDir string) ([]string, error)

LocalTags looks up the tags in the given locally cloned repo. If there are no tags, that's not an error, and the returned slice is len 0. The return values are sorted lexicographically.

func Workspace added in v0.4.0

func Workspace(ctx context.Context, path string) (string, bool, error)

Workspace looks for the presence of a .git directory in parent directories to determine the root directory of the git workspace containing "path". Returns false if the given path is not inside a git workspace.

The input path need not actually exist yet. For example, suppose "/a/b" is a git workspace, which means that "/a/b/.git" is a directory that exists. Calling Workspace("/a/b/c") will return "/a/b" whether or not "c" actually exists yet. This supports the case where the user is rendering into a directory that doesn't exist yet but will be created by the render operation.

Types

type NoSuchVersionError added in v0.9.2

type NoSuchVersionError struct {
	Version string
}

NoSuchVersionError is returned from Checkout when the requested version doesn't exist.

func (*NoSuchVersionError) Error added in v0.9.2

func (e *NoSuchVersionError) Error() string

Jump to

Keyboard shortcuts

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