git

package
v0.6.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoTagsFound = errors.New("no tags found")

ErrNoTagsFound is returned when no tags are found in the current git repository

Functions

func Diff added in v0.6.0

func Diff(ctx context.Context, opts ...DiffOption) (string, error)

Diff returns the current diff of the git repository with a specified format and variadic slice of options. An error is returned if the diff cannot be retrieved.

func LatestTag

func LatestTag(ctx context.Context, opts ...LatestTagOption) (string, error)

LatestTag returns the latest tag for the current git repository given a variadic slice of options. An error is returned if the latest tag cannot be retrieved.

func LatestVersion added in v0.6.0

func LatestVersion(ctx context.Context, opts ...LatestVersionOption) (string, error)

LatestVersion returns the latest tag, "v" prefixed, as determined by comparing all tags as semantic versions. An error will be returned if there are no available tags or any tag is not parseable as a semantic version.

func ListTags

func ListTags(ctx context.Context, opts ...ListTagsOption) ([]string, error)

ListTags lists all tags in the current git repository given a variadic slice of options. An error is returned if the the tags cannot be listed.

func RevParse

func RevParse(ctx context.Context, opts ...RevParseOption) (string, error)

RevParse runs "git rev-parse" given a RevParseFormat and a variadic slice of options. An error is returned if a value cannot be obtained.

func Status added in v0.6.0

func Status(ctx context.Context, opts ...StatusOption) (string, error)

Status returns the current status of the git repository with the given format and a variadic slice of options. An eror is returned if the status cannot be retrieved.

Types

type DiffConfig added in v0.6.0

type DiffConfig struct {
	Format     DiffFormat
	WorkingDir string
}

func (*DiffConfig) Option added in v0.6.0

func (c *DiffConfig) Option(opts ...DiffOption)

type DiffFormat added in v0.6.0

type DiffFormat string
const (
	// DiffFormatNameOnly returns only the names
	// of modified files.
	DiffFormatNameOnly DiffFormat = "name only"
	// DiffFormatNameStatus returns both the name
	// and type of change for modified files.
	DiffFormatNameStatus DiffFormat = "name status"
)

func (DiffFormat) ToGitValue added in v0.6.0

func (f DiffFormat) ToGitValue() string

type DiffOption added in v0.6.0

type DiffOption interface {
	ConfigureDiff(*DiffConfig)
}

type LatestTagConfig

type LatestTagConfig struct {
	WorkingDir string
}

func (*LatestTagConfig) Option

func (c *LatestTagConfig) Option(opts ...LatestTagOption)

type LatestTagOption

type LatestTagOption interface {
	ConfigureLatestTag(*LatestTagConfig)
}

type LatestVersionConfig added in v0.6.0

type LatestVersionConfig struct {
	WorkingDir string
}

func (*LatestVersionConfig) Option added in v0.6.0

func (c *LatestVersionConfig) Option(opts ...LatestVersionOption)

type LatestVersionOption added in v0.6.0

type LatestVersionOption interface {
	ConfigureLatestVersion(*LatestVersionConfig)
}

type ListTagsConfig

type ListTagsConfig struct {
	Sorted     bool
	SortKey    SortKey
	WorkingDir string
}

func (*ListTagsConfig) Option

func (c *ListTagsConfig) Option(opts ...ListTagsOption)

type ListTagsOption

type ListTagsOption interface {
	ConfigureListTags(c *ListTagsConfig)
}

type RevParseConfig

type RevParseConfig struct {
	Format     RevParseFormat
	WorkingDir string
}

func (*RevParseConfig) Option

func (c *RevParseConfig) Option(opts ...RevParseOption)

type RevParseFormat

type RevParseFormat string

RevParseFormat is an enum of format options for "git rev-parse"

const (
	// RevParseFormatAbbrevRef is "--abbrev-ref"
	RevParseFormatAbbrevRef RevParseFormat = "abbrev-ref"
	// RevParseFormatShort is "--short"
	RevParseFormatShort RevParseFormat = "short"
	// RevParseFormatTopLevel is "--show-toplevel"
	RevParseFormatTopLevel RevParseFormat = "top-level"
)

func (RevParseFormat) ToGitValue

func (f RevParseFormat) ToGitValue() string

type RevParseOption

type RevParseOption interface {
	ConfigureRevParse(*RevParseConfig)
}

type SortKey

type SortKey string

SortKey is a key used to sort tags.

const (
	// SortKeyNone is an empty sort key.
	SortKeyNone SortKey = ""
	// SortKeyCreationDate is a key which sorts by
	// tag creation date.
	SortKeyCreationDate SortKey = "creation date"
	// SortKeyRefName is a key which sorts by refname.
	SortKeyRefName SortKey = "refname"
)

func (SortKey) ToGitValue

func (k SortKey) ToGitValue() string

type StatusConfig added in v0.6.0

type StatusConfig struct {
	Format     StatusFormat
	WorkingDir string
}

func (*StatusConfig) Option added in v0.6.0

func (c *StatusConfig) Option(opts ...StatusOption)

type StatusFormat added in v0.6.0

type StatusFormat string
const (
	// StatusFormatLong returns the long form of status.
	StatusFormatLong StatusFormat = "long"
	// StatusFormatPorcelain returns a consistent
	// status without terminal control codes.
	StatusFormatPorcelain StatusFormat = "porcelain"
	// StatusFormatShort returns the short form of status
	StatusFormatShort StatusFormat = "short"
)

func (StatusFormat) ToGitValue added in v0.6.0

func (f StatusFormat) ToGitValue() string

type StatusOption added in v0.6.0

type StatusOption interface {
	ConfigureStatus(*StatusConfig)
}

type WithDiffFormat added in v0.6.1

type WithDiffFormat DiffFormat

WithDiffFormat applies the given DiffFormat

func (WithDiffFormat) ConfigureDiff added in v0.6.1

func (w WithDiffFormat) ConfigureDiff(c *DiffConfig)

type WithRevParseFormat added in v0.6.1

type WithRevParseFormat RevParseFormat

WithRevParseFormat applies the given RevParseFormat

func (WithRevParseFormat) ConfigureRevParse added in v0.6.1

func (w WithRevParseFormat) ConfigureRevParse(c *RevParseConfig)

type WithSortKey

type WithSortKey SortKey

With SortKey applies the given sort key.

func (WithSortKey) ConfigureListTags

func (w WithSortKey) ConfigureListTags(c *ListTagsConfig)

type WithSorted

type WithSorted bool

WithSorted enables sorting.

func (WithSorted) ConfigureListTags

func (w WithSorted) ConfigureListTags(c *ListTagsConfig)

type WithStatusFormat added in v0.6.1

type WithStatusFormat StatusFormat

WithStatusFormat applies the given StatusFormat

func (WithStatusFormat) ConfigureStatus added in v0.6.1

func (w WithStatusFormat) ConfigureStatus(c *StatusConfig)

type WithWorkingDirectory

type WithWorkingDirectory string

WithWorkingDirectory applies the given working directory.

func (WithWorkingDirectory) ConfigureDiff added in v0.6.0

func (w WithWorkingDirectory) ConfigureDiff(c *DiffConfig)

func (WithWorkingDirectory) ConfigureLatestTag

func (w WithWorkingDirectory) ConfigureLatestTag(c *LatestTagConfig)

func (WithWorkingDirectory) ConfigureLatestVersion added in v0.6.0

func (w WithWorkingDirectory) ConfigureLatestVersion(c *LatestVersionConfig)

func (WithWorkingDirectory) ConfigureListTags

func (w WithWorkingDirectory) ConfigureListTags(c *ListTagsConfig)

func (WithWorkingDirectory) ConfigureRevParse

func (w WithWorkingDirectory) ConfigureRevParse(c *RevParseConfig)

func (WithWorkingDirectory) ConfigureStatus added in v0.6.0

func (w WithWorkingDirectory) ConfigureStatus(c *StatusConfig)

Jump to

Keyboard shortcuts

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