version

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package version provides utilities and methods for getting the base version of a repository and calculating the patch level.

Index

Constants

This section is empty.

Variables

View Source
var ErrLastCommitNotFound = errors.New("version: last commit not found")

ErrLastCommitNotFound is an error emitted if the last commit cannot be found.

Functions

func CountCommits

func CountCommits(r *git.Repository, hash plumbing.Hash) (count uint64, err error)

CountCommits returns the number of commits in the repo since the specified hash.

func Repo

func Repo(r *git.Repository, vr Versioner) (v *semver.Version, err error)

Repo returns the version of the repo.

Repo uses the Versioner to determine the base version of the repository and adjusts the patch level by the number of commits since the base version was last set.

Types

type File

type File struct {
	RepoPath string
	FileName string
}

File implements Versioner using a file in the repository.

func (*File) LastCommit

func (f *File) LastCommit(r *git.Repository) (hash plumbing.Hash, err error)

LastCommit returns the commit hash containing the last change to FileName.

func (*File) Version

func (f *File) Version() (v *semver.Version, err error)

Version returns the base version found by parsing the contents of FileName.

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

Tag implements Versioner using a tag in the repository.

func (*Tag) LastCommit

func (t *Tag) LastCommit(r *git.Repository) (hash plumbing.Hash, err error)

LastCommit returns the commit hash containing of the most recent version tag. A tag is considered to contain a version if the tag name is parsable as a semantic version (https://semver.org/) with an optional leading 'v' (e.g. v1.2.3 or 5.3.0).

func (*Tag) Version

func (t *Tag) Version() (v *semver.Version, err error)

Version returns the base version found by parsing the tag name.

type Versioner

type Versioner interface {
	LastCommit(r *git.Repository) (hash plumbing.Hash, err error)
	Version() (v *semver.Version, err error)
}

Versioner determines the base version and commit hash for the last base version update.

Jump to

Keyboard shortcuts

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