diff --git a/src/Cli/Cli.csproj b/src/Cli/Cli.csproj
index 4245e1c..368d594 100644
--- a/src/Cli/Cli.csproj
+++ b/src/Cli/Cli.csproj
@@ -9,7 +9,7 @@
Novaloop.UpdateTag
Updates the tag of a repo to the next chosen version according the semver symantic.
semver;update-tag;tag;git
- 0.1.4
+ 0.1.5
Matthias Langhard
Novaloop AG
https://gitlab.com/novaloop-oss/novaloop.update-tag
diff --git a/src/Core/Models/Version.cs b/src/Core/Models/Version.cs
index d7aa238..a1be776 100644
--- a/src/Core/Models/Version.cs
+++ b/src/Core/Models/Version.cs
@@ -141,7 +141,7 @@ namespace Application.Models
return nextVersion;
}
- public Version CreateRc()
+ public Version CreatePatchRc()
{
if (Rc != null)
{
@@ -149,6 +149,36 @@ namespace Application.Models
}
var nextVersion = Copy();
+ nextVersion.Patch++;
+ nextVersion.Rc = 0;
+ return nextVersion;
+ }
+
+ public Version CreateMinorRc()
+ {
+ if (Rc != null)
+ {
+ throw new ArgumentException("Cannot create RC. Already an RC.");
+ }
+
+ var nextVersion = Copy();
+ nextVersion.Minor++;
+ nextVersion.Patch = 0;
+ nextVersion.Rc = 0;
+ return nextVersion;
+ }
+
+ public Version CreateMajorRc()
+ {
+ if (Rc != null)
+ {
+ throw new ArgumentException("Cannot create RC. Already an RC.");
+ }
+
+ var nextVersion = Copy();
+ nextVersion.Major++;
+ nextVersion.Minor = 0;
+ nextVersion.Patch = 0;
nextVersion.Rc = 0;
return nextVersion;
}
diff --git a/src/Core/Models/VersionInformation.cs b/src/Core/Models/VersionInformation.cs
index d8cc7b7..8ef826e 100644
--- a/src/Core/Models/VersionInformation.cs
+++ b/src/Core/Models/VersionInformation.cs
@@ -14,10 +14,12 @@ namespace Application.Models
}
else
{
- NextVersions.Add(new NextVersion("rc", currentVersion.CreateRc()));
- NextVersions.Add(new NextVersion("patch", currentVersion.NextPatch()));
- NextVersions.Add(new NextVersion("minor", currentVersion.NextMinor()));
- NextVersions.Add(new NextVersion("major", currentVersion.NextMajor()));
+ NextVersions.Add(new NextVersion("patch-rc", currentVersion.CreatePatchRc()));
+ NextVersions.Add(new NextVersion("minor-rc", currentVersion.CreateMinorRc()));
+ NextVersions.Add(new NextVersion("minor-rc", currentVersion.CreateMajorRc()));
+ NextVersions.Add(new NextVersion("patch ", currentVersion.NextPatch()));
+ NextVersions.Add(new NextVersion("minor ", currentVersion.NextMinor()));
+ NextVersions.Add(new NextVersion("major ", currentVersion.NextMajor()));
}
}
diff --git a/tests/update-tag.tests/VersionInformationTests.cs b/tests/update-tag.tests/VersionInformationTests.cs
index af32a1a..e48e9a1 100644
--- a/tests/update-tag.tests/VersionInformationTests.cs
+++ b/tests/update-tag.tests/VersionInformationTests.cs
@@ -18,13 +18,13 @@ namespace UpdateTag.Tests
var versions = versionInformation.NextVersions.Select(nv => nv.Version.ToString()).ToList();
// Assert
- Assert.Contains("1.0.1-RC.2", versions);
- Assert.Contains("1.0.1", versions);
+ Assert.Contains("1.0.1-RC.2", versions); // next rc
+ Assert.Contains("1.0.1", versions); // release rc
Assert.Equal(2, versions.Count);
}
[Fact]
- public void CorrectNextVersionsFromMinor()
+ public void CorrectNextVersionsFromNonRc()
{
// Arrange
@@ -36,11 +36,13 @@ namespace UpdateTag.Tests
// Assert
- Assert.Contains("1.0.1-RC.0", versions);
- Assert.Contains("1.0.2", versions);
- Assert.Contains("1.1.0", versions);
- Assert.Contains("2.0.0", versions);
- Assert.Equal(4, versions.Count);
+ Assert.Contains("1.0.2-RC.0", versions); // patch RC
+ Assert.Contains("1.1.0-RC.0", versions); // minor RC
+ Assert.Contains("2.0.0-RC.0", versions); // major RC
+ Assert.Contains("1.0.2", versions); // next patch
+ Assert.Contains("1.1.0", versions); // next minor
+ Assert.Contains("2.0.0", versions); // next major
+ Assert.Equal(6, versions.Count);
}
}
}
\ No newline at end of file
diff --git a/tests/update-tag.tests/VersionTests.cs b/tests/update-tag.tests/VersionTests.cs
index 135f605..49f8250 100644
--- a/tests/update-tag.tests/VersionTests.cs
+++ b/tests/update-tag.tests/VersionTests.cs
@@ -49,6 +49,33 @@ namespace UpdateTag.Tests
Assert.Equal(expected, version.ToString());
}
+ [Theory]
+ [InlineData(1, 1, 1, null, "", "1.1.2-RC.0")]
+ [InlineData(1, 1, 1, null, "ErpNext", "1.1.2-RC.0+ErpNext")]
+ public void CreatePatchRc(int major, int minor, int patch, string rc, string service, string expected)
+ {
+ var version = new Version(major, minor, patch, rc, service).CreatePatchRc();
+ Assert.Equal(expected, version.ToString());
+ }
+
+ [Theory]
+ [InlineData(1, 1, 1, null, "", "1.2.0-RC.0")]
+ [InlineData(1, 1, 1, null, "ErpNext", "1.2.0-RC.0+ErpNext")]
+ public void CreateMinorRc(int major, int minor, int patch, string rc, string service, string expected)
+ {
+ var version = new Version(major, minor, patch, rc, service).CreateMinorRc();
+ Assert.Equal(expected, version.ToString());
+ }
+
+ [Theory]
+ [InlineData(1, 1, 1, null, "", "2.0.0-RC.0")]
+ [InlineData(1, 1, 1, null, "ErpNext", "2.0.0-RC.0+ErpNext")]
+ public void CreateMajroRc(int major, int minor, int patch, string rc, string service, string expected)
+ {
+ var version = new Version(major, minor, patch, rc, service).CreateMajorRc();
+ Assert.Equal(expected, version.ToString());
+ }
+
[Theory]
[InlineData(1, 1, 1, "RC.4", "", "1.1.1")]
[InlineData(1, 1, 1, "RC.4", "ErpNext", "1.1.1+ErpNext")]