Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoSubmodule = errors.New("no submodule found") ErrNotRelease = errors.New("HEAD is not a release commit") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // CreateTag represents whether to create the tag. CreateTag bool // ExcludeModules is a list of module names or paths to exclude. ExcludeModules []string // IgnoreModules controls whether gotagger will ignore the existence of // go.mod files when determining how to version a project. IgnoreModules bool // RemoteName represents the name of the remote repository. Defaults to origin. RemoteName string // PreMajor controls whether gotagger will increase the major version from 0 // to 1 for breaking changes. PreMajor bool // PushTag represents whether to push the tag to the remote git repository. PushTag bool // VersionPrefix is a string that will be added to the front of the version. Defaults to 'v'. VersionPrefix string // DirtyWorktreeIncrement is a string that sets how to increment the version // if there are no new commits, but the worktree is "dirty". DirtyWorktreeIncrement mapper.Increment // CommitTypeTable used for looking up version increments based on the commit type. CommitTypeTable mapper.Table // Force controls whether gotagger will create a tag even if HEAD is not a "release" commit. Force bool // Paths is a list of sub-paths within the repo to restrict the git // history used to calculate a version. The versions returned will be // prefixed with their path. Paths []string }
Config represents how to tag a repo.
If no default is mentioned, the option defaults to go's zero-value.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig returns a Config with default options set.
If an option is not mentioned, then the default is the zero-value for its type.
- RemoteName origin
- VersionPrefix v
func (*Config) ParseJSON ¶ added in v0.8.0
ParseJSON unmarshals a byte slice containing mappings of commit type to semver increment. Mappings determine how much to increment the semver based on the commit type. The 'release' commit type has special meaning to gotagger and cannot be overridden in the config file. Unknown commit types will fall back to the config default. Invalid increments will throw an error. Duplicate type definitions will take the last entry.
type Gotagger ¶
type Gotagger struct { Config Config // contains filtered or unexported fields }
func (*Gotagger) ModuleVersions ¶
ModuleVersions returns the current version for all go modules in the repository in the order they were found by a depth-first, lexicographically sorted search.
For example, in a repository with a root go.mod and a submodule foo/bar, the slice returned would be: []string{"v0.1.0", "bar/v0.1.0"}
If module names are passed in, then only the versions for those modules are returned.
func (*Gotagger) TagRepo ¶
TagRepo determines the current version of the repository by parsing the commit history since the previous release and returns that version. Depending on the CreateTag and PushTag configuration options tags may be created and pushed.
If the current commit contains one or more Modules footers, then tags are created for each module listed. In this case if the root module is not explicitly included in a Modules footer then it will not be included.
func (*Gotagger) Version ¶
Version returns the current version for the repository.
In a repository that contains multiple go modules, this returns the version of the first module found by a depth-first, lexicographically sorted search. Usually this is the root module, but possibly not if the repo is a monorepo with no root module.