Documentation ¶
Overview ¶
Package scope encapsulates ambit of the git-semver functionality.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBumpMajorOverflow when the major axis resets to zero ErrBumpMajorOverflow = errors.New("bump overflow: major") // ErrBumpMinorOverflow when the minor axis resets to zero ErrBumpMinorOverflow = errors.New("bump overflow: minor") // ErrBumpPatchOverflow when the patch axis resets to zero ErrBumpPatchOverflow = errors.New("bump overflow: patch") // ErrBumpPRVerOverflow when the pre-release version resets to zero ErrBumpPRVerOverflow = errors.New("bump overflow: pre-release version") )
var ( // RemoteName is the name of the remote that this tooling should work with. RemoteName = GetEnv("SEMVER_REMOTE_NAME", git.DefaultRemoteName) // PrePrefix is the default value for the pre-axis. PrePrefix = GetEnv("SEMVER_PRE_PREFIX", "pre") // UserEmail is the value for the git config user.email in the local semver repository. UserEmail = GetEnv("SEMVER_USER_EMAIL", GetEnv("GIT_AUTHOR_EMAIL", GetEnv("GIT_COMMITTER_EMAIL", "semver@semver.org"), ), ) // UserName is the value for the git config user.name in the local semver repository. UserName = GetEnv("SEMVER_USER_NAME", GetEnv("GIT_AUTHOR_NAME", GetEnv("GIT_COMMITTER_NAME", "semver"), ), ) )
Functions ¶
func WriteVersion ¶
WriteVersion writes the version string value to a file named after the current branch.
Types ¶
type Extent ¶
type Extent struct { Store *filesystem.Storage Repo *git.Repository Tree *git.Worktree Branch string }
Extent is an Open()'ed GIT repository.
type MakeOpt ¶
MakeOpt is an option passed to MakeVersion
func BumpFinal ¶
func BumpFinal() MakeOpt
BumpFinal will strip the pre-release suffix.
Example ¶
package main import ( "fmt" "github.com/edgexfoundry/git-semver/scope" ) func main() { ver, err := scope.MakeVersion("1.2.3-dev.4", scope.BumpFinal()) if err != nil { fmt.Printf("%s", err) } else { fmt.Printf("%s", ver) } }
Output: 1.2.3
func BumpMajor ¶
func BumpMajor() MakeOpt
BumpMajor will bump the major axis.
Example ¶
package main import ( "fmt" "github.com/edgexfoundry/git-semver/scope" ) func main() { ver, err := scope.MakeVersion("1.2.3-dev.4", scope.BumpMajor()) if err != nil { fmt.Printf("%s", err) } else { fmt.Printf("%s", ver) } }
Output: 2.0.0
func BumpMinor ¶
func BumpMinor() MakeOpt
BumpMinor will bump the minor axis.
Example ¶
package main import ( "fmt" "github.com/edgexfoundry/git-semver/scope" ) func main() { ver, err := scope.MakeVersion("1.2.3-dev.4", scope.BumpMinor()) if err != nil { fmt.Printf("%s", err) } else { fmt.Printf("%s", ver) } }
Output: 1.3.0
func BumpPatch ¶
func BumpPatch() MakeOpt
BumpPatch will bump the patch axis.
Example ¶
package main import ( "fmt" "github.com/edgexfoundry/git-semver/scope" ) func main() { ver, err := scope.MakeVersion("1.2.3-dev.4", scope.BumpPatch()) if err != nil { fmt.Printf("%s", err) } else { fmt.Printf("%s", ver) } }
Output: 1.2.4
func BumpPre ¶
BumpPre will bump the pre-release suffix. Passing a different prefix than what is currently encoded will bump from zero with the new pre-release.
Example (Dev) ¶
package main import ( "fmt" "github.com/edgexfoundry/git-semver/scope" ) func main() { ver, err := scope.MakeVersion("1.2.3-dev.4", scope.BumpPre("dev")) if err != nil { fmt.Printf("%s", err) } else { fmt.Printf("%s", ver) } }
Output: 1.2.3-dev.5
Example (Pre) ¶
package main import ( "fmt" "github.com/edgexfoundry/git-semver/scope" ) func main() { ver, err := scope.MakeVersion("1.2.3-dev.4", scope.BumpPre("pre")) if err != nil { fmt.Printf("%s", err) } else { fmt.Printf("%s", ver) } }
Output: 1.2.3-pre.1
type Version ¶
Version type alias
func MakeVersion ¶
MakeVersion parses the version string and applies the supplied options.
func ReadVersion ¶
ReadVersion reads the semver version for the current branch.