Permalink
Browse files

Merge pull request #122 from RubenWillems/master

add properties for formatting the parts of the assembly version labeller (Feature #139)
  • Loading branch information...
2 parents 2f186f3 + 28eb10d commit 8df5ab638bbcc97d398e114bf84b96ee0845b1e1 @RubenWillems RubenWillems committed May 28, 2012
@@ -50,6 +50,22 @@ public void GenerateLabel()
Assert.AreEqual(new Version(0, 0, 1, 30).ToString(), labeller.Generate(result));
}
+
+ [Test]
+ public void GenerateLabelWithLabelFormats()
+ {
+ labeller.MajorLabelFormat = "00";
+ labeller.MinorLabelFormat = "000";
+ labeller.BuildLabelFormat = "0000";
+ labeller.RevisionLabelFormat = "00000";
+
+ IntegrationResult result = CreateIntegrationResult();
+ AddModifications(result);
+ Assert.AreEqual("00.000.0001.00030", labeller.Generate(result));
+ }
+
+
+
[Test]
public void GenerateLabelFromNoMods()
{
@@ -91,6 +91,43 @@ public AssemblyVersionLabeller()
[ReflectorProperty("incrementOnFailure", Required = false)]
public bool IncrementOnFailure { get; set; }
+
+ /// <summary>
+ /// A format applied to the major part of the buildnumber.
+ /// </summary>
+ /// <version>1.7</version>
+ /// <default>0</default>
+ [ReflectorProperty("majorLabelFormat", Required = false)]
+ public string MajorLabelFormat { get; set; }
+
+
+ /// <summary>
+ /// A format applied to the minor part of the buildnumber.
+ /// </summary>
+ /// <version>1.7</version>
+ /// <default>0</default>
+ [ReflectorProperty("minorLabelFormat", Required = false)]
+ public string MinorLabelFormat { get; set; }
+
+
+ /// <summary>
+ /// A format applied to the build part of the buildnumber.
+ /// </summary>
+ /// <version>1.7</version>
+ /// <default>0</default>
+ [ReflectorProperty("buildLabelFormat", Required = false)]
+ public string BuildLabelFormat { get; set; }
+
+
+ /// <summary>
+ /// A format applied to the revision part of the buildnumber.
+ /// </summary>
+ /// <version>1.7</version>
+ /// <default>0</default>
+ [ReflectorProperty("revisionLabelFormat", Required = false)]
+ public string RevisionLabelFormat { get; set; }
+
+
#endregion
#region ILabeller Members
@@ -174,11 +211,12 @@ public override string Generate(IIntegrationResult integrationResult)
Log.Debug(string.Format(System.Globalization.CultureInfo.InvariantCulture,
"[assemblyVersionLabeller] Major: {0} Minor: {1} Build: {2} Revision: {3}", Major, Minor, currentBuild, currentRevision));
- Version newVersion = new Version(Major, Minor, currentBuild, currentRevision);
- Log.Debug(string.Concat("[assemblyVersionLabeller] New version is: ", newVersion.ToString()));
+ string result = string.Concat(Major.ToString(MajorLabelFormat), ".", Minor.ToString(MinorLabelFormat), ".", currentBuild.ToString(BuildLabelFormat), ".", currentRevision.ToString(RevisionLabelFormat));
+
+ Log.Debug(string.Concat("[assemblyVersionLabeller] New version is: ", result.ToString()));
// return new version string
- return newVersion.ToString();
+ return result;
}
#endregion

0 comments on commit 8df5ab6

Please sign in to comment.