diff options
| author | Max Resnick <max@ofmax.li> | 2024-04-13 23:54:49 -0700 |
|---|---|---|
| committer | Max Resnick <max@ofmax.li> | 2024-04-13 23:54:49 -0700 |
| commit | a303fdfd413a316c6934b837ab1c5e222722c0e8 (patch) | |
| tree | ed744c0a9489aa7a8327455c7b9c472b26c34e16 | |
| parent | dd8b5e9750e8c075816f1bfdc84a6e44724fae12 (diff) | |
| download | go-bumpver-a303fdfd413a316c6934b837ab1c5e222722c0e8.tar.gz | |
feat: add switch to print prior version0.2.0
| -rw-r--r-- | README.md | 21 | ||||
| -rw-r--r-- | main.go | 9 |
2 files changed, 24 insertions, 6 deletions
@@ -7,7 +7,7 @@ bumpver - print the next semantec version in a given sequence ## Usage ```bash -bumpver part [major|minor|patch] [flags] file [-|file] +bumpver part [major|minor|patch] [flags] file [-|file] ``` ## Why? @@ -20,9 +20,7 @@ bumpver part [major|minor|patch] [flags] file [-|file] ## How? -`go-bumpver` takes the sequence of version(s) from a file or stdin and prints the next version. It drops invalid versions in the sequence and only uses valid ones. It does not make a tag or change any state in git or any other VCS it only prints the next version. - -`go-bumpver` has simple but ability to bump pre-release tags using simple formating string. +`go-bumpver` takes the sequence of version(s) from a file or stdin and prints the next version. It drops invalid versions in the sequence and only uses valid ones. It does not make a tag or change any state in git or any other VCS, it only prints the next version. It also has the ability to bump pre-release tags using simple formating string. ### Inputs @@ -51,7 +49,9 @@ bumpver part [major|minor|patch] [flags] file [-|file] 3.3.4 ``` -**bump tags released on a branch** +**bump tags released along a branch** + +This example supports software that has support for multiple versions at once. E.g. version 2.X is still supported but 3.X is based off of main. ```bash ❯ bumpver patch <(git tag --merged <release branch name>) 2.1.4 @@ -77,6 +77,17 @@ bumpver part [major|minor|patch] [flags] file [-|file] 4.0.0 ``` +***prior version*** +Getting the last version could be useful for generating diffs, release notes etc. + +``` +❯ bumpver major --last-version <(git tag -l) +3.8.1 +❯ bumpver major <(git tag -l) +4.0.0 +``` + + ### Pre-release Pre-releases can be formatted in a way that can be easily bumped. Providing `--prerelease` will generate a new prerelease for the given bump. Meaning if you use `major --prerelease` with the last version 1.2.2 will give `2.0.0-RC.0`. @@ -132,7 +132,9 @@ var ( validPartArgs = []string{"major", "minor", "patch"} preReleaseFmtArgs = make(map[string]string) preRelease bool - rootCmd = &cobra.Command{ + printLastVersion bool + + rootCmd = &cobra.Command{ Use: "bumpver part [major|minor|patch] file [-|file]", Short: "A tool for bumping semver git tags.", Example: cmdExamples, @@ -169,6 +171,10 @@ var ( if (lastVersion == &semver.Version{}) { return errors.New("No tags found. Not doing anything") } + if printLastVersion { + fmt.Fprint(cmd.OutOrStdout(), lastVersion) + return nil + } versionPart := "" if preRelease { versionPart = part @@ -274,6 +280,7 @@ func init() { } rootCmd.PersistentFlags().BoolVarP(&preRelease, "prerelease", "p", false, "create a prerelease tag for the (major|minor|patch)") + rootCmd.PersistentFlags().BoolVarP(&printLastVersion, "last-version", "l", false, "print version just before the bump that would occur") rootCmd.PersistentFlags().String("prerelease-fmt", "PR.$KeyArg PR_NUM.$BumpInt", "The format string for prerelease versions") rootCmd.PersistentFlags().StringToStringVarP(&preReleaseFmtArgs, "key-args", "k", nil, "key=arg for the fmt string") rootCmd.PersistentFlags().String("repo-dir", cwd, "repo to examine") |