git

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

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

Clone checks out the given branch, tag or long commit SHA from the given repo. It uses the git CLI already installed on the system.

To optimize storage and bandwidth, the full git history is not fetched.

"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 ParseSemverTag added in v0.4.0

func ParseSemverTag(t string) (*semver.Version, error)

ParseSemverTag parses a string of the form "v1.2.3" into a semver tag. In abc CLI, we require that tags begin with "v", and anything else is a parse error.

WARNING: the returned semver.Version has had the "v" prefix stripped, so the string returned from .Original() will be missing the "v".

func RemoteTags added in v0.5.0

func RemoteTags(ctx context.Context, remote string) ([]string, error)

RemoteTags looks up the tags in the given remote repo. If there are no tags, that's not an error, and the returned slice is len 0.

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

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

This section is empty.

Jump to

Keyboard shortcuts

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