Skip to content
Snippets Groups Projects
Commit 81aea839 authored by Christoph Witzko's avatar Christoph Witzko
Browse files

fix: if allowInitialDevelopmentVersions is set the major version should never be updated

parent 79334cdb
No related branches found
No related tags found
No related merge requests found
...@@ -179,7 +179,7 @@ func SetFlags(cmd *cobra.Command) { ...@@ -179,7 +179,7 @@ func SetFlags(cmd *cobra.Command) {
cmd.Flags().Bool("ghr", false, "create a .ghr file with the parameters for ghr") cmd.Flags().Bool("ghr", false, "create a .ghr file with the parameters for ghr")
cmd.Flags().Bool("no-ci", false, "run semantic-release locally") cmd.Flags().Bool("no-ci", false, "run semantic-release locally")
cmd.Flags().Bool("dry", false, "do not create release") cmd.Flags().Bool("dry", false, "do not create release")
cmd.Flags().Bool("allow-initial-development-versions", false, "semantic-release will start your initial development release at 0.1.0") cmd.Flags().Bool("allow-initial-development-versions", false, "semantic-release will start your initial development release at 0.1.0 and will handle breaking changes as minor version updates. This option will be ignored if a release with major version greater than or equal 1 exists.")
cmd.Flags().Bool("allow-no-changes", false, "exit with code 0 if no changes are found, useful if semantic-release is automatically run") cmd.Flags().Bool("allow-no-changes", false, "exit with code 0 if no changes are found, useful if semantic-release is automatically run")
cmd.Flags().Bool("force-bump-patch-version", false, "increments the patch version if no changes are found") cmd.Flags().Bool("force-bump-patch-version", false, "increments the patch version if no changes are found")
cmd.Flags().Bool("prepend-changelog", false, "if the changelog file already exist the new changelog is prepended") cmd.Flags().Bool("prepend-changelog", false, "if the changelog file already exist the new changelog is prepended")
......
...@@ -33,6 +33,12 @@ func applyChange(rawVersion string, rawChange *Change, allowInitialDevelopmentVe ...@@ -33,6 +33,12 @@ func applyChange(rawVersion string, rawChange *Change, allowInitialDevelopmentVe
change.Major = true change.Major = true
} }
// never allow major version changed if allowInitialDevelopmentVersions is set
if allowInitialDevelopmentVersions && version.Major() == 0 && change.Major {
change.Major = false
change.Minor = true
}
if allowInitialDevelopmentVersions && version.Major() == 0 && version.Minor() == 0 { if allowInitialDevelopmentVersions && version.Major() == 0 && version.Minor() == 0 {
change.Minor = true change.Minor = true
} }
......
...@@ -50,7 +50,7 @@ func TestApplyChange(t *testing.T) { ...@@ -50,7 +50,7 @@ func TestApplyChange(t *testing.T) {
{"0.0.0", NoChange, "0.1.0", true, false}, {"0.0.0", NoChange, "0.1.0", true, false},
{"0.0.0", PatchChange, "0.1.0", true, false}, {"0.0.0", PatchChange, "0.1.0", true, false},
{"0.0.0", MinorChange, "0.1.0", true, false}, {"0.0.0", MinorChange, "0.1.0", true, false},
{"0.0.0", MajorChange, "1.0.0", true, false}, {"0.0.0", MajorChange, "0.1.0", true, false},
{"1.0.0", NoChange, "", false, false}, {"1.0.0", NoChange, "", false, false},
{"1.0.0", NoChange, "1.0.1", false, true}, {"1.0.0", NoChange, "1.0.1", false, true},
...@@ -63,6 +63,11 @@ func TestApplyChange(t *testing.T) { ...@@ -63,6 +63,11 @@ func TestApplyChange(t *testing.T) {
{"2.0.0-beta", MajorChange, "2.0.0-beta.1", false, false}, {"2.0.0-beta", MajorChange, "2.0.0-beta.1", false, false},
{"2.0.0-beta.2", MajorChange, "2.0.0-beta.3", false, false}, {"2.0.0-beta.2", MajorChange, "2.0.0-beta.3", false, false},
{"2.0.0-beta.1.1", MajorChange, "2.0.0-beta.2", false, false}, {"2.0.0-beta.1.1", MajorChange, "2.0.0-beta.2", false, false},
{"0.1.0", MajorChange, "0.2.0", true, false},
{"1.0.0", MajorChange, "2.0.0", true, false},
{"0.1.0", MinorChange, "0.2.0", true, false},
{"0.1.0", NoChange, "0.1.1", true, true},
} }
for _, tc := range testCases { for _, tc := range testCases {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment