git

package
v0.0.0-...-380e484 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(path string, args ...string) error

Add invokes git-add in the specified path passing the provided arguments.

func Changed

func Changed(repository string, commit string, paths ...string) ([]string, error)

Changed reports the list of files that changed for a specific commit or tag.

func Changes

func Changes(repository string, from, to string, paths ...string) ([]string, error)

Changes outputs a list of files for the repository that have changed at the given paths between from and to commit-like references. If no paths are provided then all files that changed between the two tree-ish (commit or tag) references are returned.

func Commit

func Commit(path, message string) error

Commit commits the staged contents in the specified repository path using the provided message.

func Git

func Git(path string, arguments ...string) (output []byte, err error)

Git executes the git with the provided arguments. The command is executed in the provided directory path.

func LsTree

func LsTree(repository, tree string, path ...string) ([]string, error)

LsTree lists the files present in the tree-ish for the repository. An optional set of one or more paths can be provided to limit the output file paths.

func Tag

func Tag(path, tag, message string, commit string) error

Tag invokes git-tag is the specified path, creating the given annotated tag at the given commit with the provided message.

func Tags

func Tags(path string) ([]string, error)

Tags returns a slice of Git tags at the repository located at path

func ToModuleTag

func ToModuleTag(modulePath string, version string) (string, error)

ToModuleTag converts the relative module path and semver version string to a git tag that can be used to identify the module version. For example:

Path: .              Version: v1.2.3 => v1.2.3
Path: service/s3     Version: v0.2.3 => service/s3/v0.2.3
Path: service/s3     Version: v1.2.3 => service/s3/v1.2.3
Path: service/s3/v2  Version: v2.2.3 => service/s3/v2.2.3
Path: service/s3/v3  Version: v2.2.3 => error

Types

type ModuleTags

type ModuleTags map[string][]string

ModuleTags is a map of module paths to a slice of tagged Go semver versions. Root module tags will be placed in the map at ".". Major versions > v1 will be added to the map with the semver major version appended to the module path.

Versions will be sorted in the slice from highest to lowest by comparing the values following semantic versioning rules.

Example:

. => ["v1.2.3", "v1.0.0"]
v2 => ["v2.0.0"]
sub/module => ["v1.2.3"]
sub/module/v2 => ["v2.2.3"]

func ParseModuleTags

func ParseModuleTags(tags []string) ModuleTags

ParseModuleTags parses a list of Git tags into a set of ModuleTags. Tags that are not semvar compliant with Go will be ignored.

func (ModuleTags) Add

func (r ModuleTags) Add(tag string) bool

Add adds the given tag to the ModuleTags

func (ModuleTags) Latest

func (r ModuleTags) Latest(module string) (string, bool)

Latest returns the latest tag for the given relative module path. Returns false if the module version is not known.

Jump to

Keyboard shortcuts

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