Skip to content
Snippets Groups Projects
Verified Commit 3957b216 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: new flag exit-code-if-no-bump #4

parent d5438556
No related branches found
No related tags found
No related merge requests found
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="version auto --git" type="GoApplicationRunConfiguration" factoryName="Go Application"> <configuration default="false" name="version auto --git" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="version" /> <module name="version" />
<working_directory value="$PROJECT_DIR$" /> <working_directory value="$PROJECT_DIR$/../../alvine/components/alvine.dispatcher" />
<parameters value="auto --git" /> <parameters value="auto --git" />
<EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.GolandRunConfigurationExtension"> <EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.GolandRunConfigurationExtension">
<option name="DIRENV_ENABLED" value="false" /> <option name="DIRENV_ENABLED" value="false" />
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<excludeFolder url="file://$MODULE_DIR$/.devenv" /> <excludeFolder url="file://$MODULE_DIR$/.devenv" />
<excludeFolder url="file://$MODULE_DIR$/.direnv" /> <excludeFolder url="file://$MODULE_DIR$/.direnv" />
<excludeFolder url="file://$MODULE_DIR$/build" /> <excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/.task" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
......
...@@ -81,6 +81,15 @@ It is important to note that this feature requires that your commit messages ...@@ -81,6 +81,15 @@ It is important to note that this feature requires that your commit messages
follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
message format. message format.
The `exit-code-if-no-bump` flag can be used to make the command exit with a non-zero exit.
This is useful for CI/CD pipelines.
```bash
version auto --exit-code-if-no-bump
```
In this case, the command will exit with the exit code 1 if no version bump is required.
**Predict** **Predict**
The `predict` command allows you to predict the next version based on the The `predict` command allows you to predict the next version based on the
......
...@@ -31,6 +31,7 @@ type commandLineOptions struct { ...@@ -31,6 +31,7 @@ type commandLineOptions struct {
Date struct { Date struct {
} `command:"date" description:"print the current date and time in the format YYYYMMDDHHMMSS"` } `command:"date" description:"print the current date and time in the format YYYYMMDDHHMMSS"`
Auto struct { Auto struct {
ExitCode bool `short:"e" long:"exit-code-if-no-bump" description:"exit code to use if no notable changes are found" default:"0"`
} `command:"auto" description:"check the git repository and increase the version if necessary. This implies --git"` } `command:"auto" description:"check the git repository and increase the version if necessary. This implies --git"`
Predict struct { Predict struct {
} `command:"predict" description:"predict the next version based on the git history. This implies --git"` } `command:"predict" description:"predict the next version based on the git history. This implies --git"`
...@@ -178,7 +179,13 @@ func executeCommand() { ...@@ -178,7 +179,13 @@ func executeCommand() {
case OtherCommit: case OtherCommit:
fmt.Println("No notable changes found.") fmt.Println("No notable changes found.")
fmt.Println("If you want to force a version\nincrease, use the major, minor\nor patch command.") fmt.Println("If you want to force a version\nincrease, use the major, minor\nor patch command.")
os.Exit(0)
exitCode := 0
if arguments.Auto.ExitCode {
exitCode = 1
}
os.Exit(exitCode)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment