aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md21
-rw-r--r--main.go9
2 files changed, 24 insertions, 6 deletions
diff --git a/README.md b/README.md
index c633c31..597a4ff 100644
--- a/README.md
+++ b/README.md
@@ -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`.
diff --git a/main.go b/main.go
index dba9462..8fd73a1 100644
--- a/main.go
+++ b/main.go
@@ -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")