cli

package
v0.0.0-...-801eb32 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCommand = &cobra.Command{
	Use:   "get-next-version",
	Short: "Get the next version according for semantic versioning",
	Long:  "Get the next version according for semantic versioning.",
	Run: func(_ *cobra.Command, _ []string) {
		validTargets := []string{
			"github-action",
			"json",
			"version",
		}

		if isValid, prefixValidationError := util.IsValidVersionPrefix(rootPrefixFlag); !isValid {
			log.Fatal().Msgf("invalid version prefix %+q", prefixValidationError)
		}

		if !slices.Contains(validTargets, rootTargetFlag) {
			log.Fatal().Msg("invalid target")
		}

		repository, err := gogit.PlainOpen(rootRepositoryFlag)
		if err != nil {
			log.Fatal().Msg(err.Error())
		}

		var nextVersion semver.Version
		var hasNextVersion bool
		result, err := git.GetConventionalCommitTypesSinceLastRelease(repository)
		if err != nil {
			log.Fatal().Msg(err.Error())
		} else {
			nextVersion, hasNextVersion = versioning.CalculateNextVersion(result.LatestReleaseVersion, result.ConventionalCommitTypes)
		}

		err = target.WriteOutput(nextVersion, hasNextVersion, rootTargetFlag, rootPrefixFlag)
		if err != nil {
			log.Fatal().Err(err).Msg("could not write output")
		}
	},
}
View Source
var VersionCommand = &cobra.Command{
	Use:   "version",
	Short: "Prints the get-next-version version",
	Long:  "Prints the get-next-version version.",
	Run: func(command *cobra.Command, args []string) {
		fmt.Println("get-next-version " + version.Version)
		fmt.Println("Revision " + version.GitVersion)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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