modes

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Auto = "auto"

Auto mode name for AutoMode.

View Source
const GitBranch = "git-branch"

GitBranch mode name for GitBranchMode.

View Source
const GitCommit = "git-commit"

GitCommit mode name for GitCommitMode.

View Source
const Major = "major"

Major semver version level for major

View Source
const Minor = "minor"

Minor semver version level for minor

View Source
const Patch = "patch"

Patch semver version level for patch

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	GitBranchMode GitBranchMode
	GitCommitMode GitCommitMode
}

API an API to work with different modes.

func NewAPI

func NewAPI(gitBranchMode GitBranchMode, gitCommitMode GitCommitMode) API

NewAPI creates a new semver mode API. Returns the new API.

func (API) SelectMode

func (api API) SelectMode(mode string) Mode

SelectMode selects the mode corresponding to the mode string. Returns the corresponding mode.

type AutoMode

type AutoMode struct {
	Modes []Mode
}

AutoMode implementation of the Mode interface. It makes use of several modes and defaults to PatchMode as a last resort.

func NewAutoMode

func NewAutoMode(modes []Mode) AutoMode

NewAutoMode creates a new AutoMode. The order of modes in the modes slices is important and determines in which order the modes are applied in AutoMode.Increment. Returns the new AutoMode.

func (AutoMode) Increment

func (autoMode AutoMode) Increment(prefix string, suffix string, targetVersion string) (nextVersion string, err error)

Increment increments a given version using AutoMode. It will attempt to increment the target version with its internal modes and defaults to PatchMode as a last resort. Returns the incremented version or an error if anything went wrong.

func (AutoMode) String added in v1.3.0

func (autoMode AutoMode) String() string

String returns a string representation of an instance.

type GitBranchMode

type GitBranchMode struct {
	Delimiters string
	GitAPI     git.API
	SemverMap  semver.Map
}

GitBranchMode implementation of the Mode interface. It increments the semver level based on the naming of the source branch of a git merge.

func NewGitBranchMode

func NewGitBranchMode(delimiters string, semverMap semver.Map) GitBranchMode

NewGitBranchMode creates a new GitBranchMode. Returns the new GitBranchMode.

func (GitBranchMode) Increment

func (mode GitBranchMode) Increment(prefix string, suffix string, targetVersion string) (nextVersion string, err error)

Increment increments the semver level based on the naming of the source branch of a git merge. Returns the incremented version or an error if the last git commit is not a merge or if no mode was detected based on the branch name.

func (GitBranchMode) String added in v1.3.0

func (mode GitBranchMode) String() string

String returns a string representation of an instance.

type GitCommitMode

type GitCommitMode struct {
	Delimiters string
	GitAPI     git.API
	SemverMap  semver.Map
}

GitCommitMode implementation of the Mode interface. It increments the semver level based on the latest git commit messages.

func NewGitCommitMode

func NewGitCommitMode(delimiters string, semverMap semver.Map) GitCommitMode

NewGitCommitMode creates a new GitCommitMode. Returns the new GitCommitMode.

func (GitCommitMode) Increment

func (mode GitCommitMode) Increment(prefix string, suffix string, targetVersion string) (nextVersion string, err error)

Increment increments a given version based on the latest git commit message. Returns the incremented version or an error if it failed to detect the mode based on the git commit.

func (GitCommitMode) String added in v1.3.0

func (mode GitCommitMode) String() string

String returns a string representation of an instance.

type MajorMode

type MajorMode struct{}

MajorMode implementation of the Mode interface. It makes use of the major level of semver versions.

func NewMajorMode

func NewMajorMode() MajorMode

NewMajorMode creates a new MajorMode. Returns the new MajorMode.

func (MajorMode) Increment

func (mode MajorMode) Increment(prefix string, suffix string, targetVersion string) (nextVersion string, err error)

Increment increments a given version using the MajorMode. Returns the incremented version.

func (MajorMode) String added in v1.3.0

func (mode MajorMode) String() string

String returns a string representation of an instance.

type MinorMode

type MinorMode struct{}

MinorMode implementation of the Mode interface. It makes use of the minor level of semver versions.

func NewMinorMode

func NewMinorMode() MinorMode

NewMinorMode creates a new MinorMode. Returns the new MinorMode.

func (MinorMode) Increment

func (mode MinorMode) Increment(prefix string, suffix string, targetVersion string) (nextVersion string, err error)

Increment increments a given version using the MinorMode. Returns the incremented version.

func (MinorMode) String added in v1.3.0

func (mode MinorMode) String() string

String returns a string representation of an instance.

type Mode

type Mode interface {
	Increment(prefix string, suffix string, targetVersion string) (nextVersion string, err error)
	String() string
}

Mode interface which increments a specific semver level.

func DetectModeFromString added in v1.7.2

func DetectModeFromString(str string, semverMap semver.Map, delimiters string) (detected Mode, err error)

func DetectModesFromString added in v1.7.2

func DetectModesFromString(str string, semverMap semver.Map, delimiters string) (detected []Mode, err error)

DetectModesFromString detects multiple modes based on a string. Mode detection is limited to PatchMode, MinorMode, MajorMode. The order of a detected modes is relative to their position in the string. Returns a slice of the detected modes.

type PatchMode

type PatchMode struct{}

PatchMode implementation of the Mode interface. It makes use of the patch level of semver versions.

func NewPatchMode

func NewPatchMode() PatchMode

NewPatchMode creates a new PatchMode. Returns the new PatchMode.

func (PatchMode) Increment

func (mode PatchMode) Increment(prefix string, suffix string, targetVersion string) (nextVersion string, err error)

Increment increments a given version using the PatchMode. Returns the incremented version.

func (PatchMode) String added in v1.3.0

func (mode PatchMode) String() string

String returns a string representation of an instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳