|
14 | 14 | /// </summary> |
15 | 15 | public class VersionOracle |
16 | 16 | { |
17 | | - /// <summary> |
18 | | - /// A regex that matches on numeric identifiers for prerelease or build metadata. |
19 | | - /// </summary> |
20 | | - private static readonly Regex NumericIdentifierRegex = new Regex(@"(?<![\w-])(\d+)(?![\w-])"); |
21 | | - |
22 | 17 | /// <summary> |
23 | 18 | /// The 0.0 version. |
24 | 19 | /// </summary> |
@@ -178,7 +173,7 @@ public IEnumerable<string> BuildMetadataWithCommitId |
178 | 173 | /// <summary> |
179 | 174 | /// Gets the version options used to initialize this instance. |
180 | 175 | /// </summary> |
181 | | - private VersionOptions VersionOptions { get; } |
| 176 | + public VersionOptions VersionOptions { get; } |
182 | 177 |
|
183 | 178 | /// <summary> |
184 | 179 | /// Gets the version string to use for the <see cref="System.Reflection.AssemblyVersionAttribute"/>. |
@@ -427,7 +422,7 @@ public IDictionary<string, string> CloudBuildVersionVars |
427 | 422 | private string SemVer2BuildMetadata => |
428 | 423 | (this.PublicRelease ? string.Empty : this.GitCommitIdShortForNonPublicPrereleaseTag) + FormatBuildMetadata(this.BuildMetadata); |
429 | 424 |
|
430 | | - private string PrereleaseVersionSemVer1 => MakePrereleaseSemVer1Compliant(this.PrereleaseVersion, this.SemVer1NumericIdentifierPadding); |
| 425 | + private string PrereleaseVersionSemVer1 => SemanticVersionExtensions.MakePrereleaseSemVer1Compliant(this.PrereleaseVersion, this.SemVer1NumericIdentifierPadding); |
431 | 426 |
|
432 | 427 | private string GitCommitIdShortForNonPublicPrereleaseTag => (string.IsNullOrEmpty(this.PrereleaseVersion) ? "-" : ".") + this.GitCommitIdShort; |
433 | 428 |
|
@@ -464,32 +459,6 @@ private static Version GetAssemblyVersion(Version version, VersionOptions versio |
464 | 459 | /// <returns>The specified string, with macros substituted for actual values.</returns> |
465 | 460 | private string ReplaceMacros(string prereleaseOrBuildMetadata) => prereleaseOrBuildMetadata?.Replace("{height}", this.VersionHeightWithOffset.ToString(CultureInfo.InvariantCulture)); |
466 | 461 |
|
467 | | - /// <summary> |
468 | | - /// Converts a semver 2 compliant "-beta.5" prerelease tag to a semver 1 compatible one. |
469 | | - /// </summary> |
470 | | - /// <param name="prerelease">The semver 2 prerelease tag, including its leading hyphen.</param> |
471 | | - /// <param name="paddingSize">The minimum number of digits to use for any numeric identifier.</param> |
472 | | - /// <returns>A semver 1 compliant prerelease tag. For example "-beta-0005".</returns> |
473 | | - private static string MakePrereleaseSemVer1Compliant(string prerelease, int paddingSize) |
474 | | - { |
475 | | - if (string.IsNullOrEmpty(prerelease)) |
476 | | - { |
477 | | - return prerelease; |
478 | | - } |
479 | | - |
480 | | - string paddingFormatter = "{0:" + new string('0', paddingSize) + "}"; |
481 | | - |
482 | | - string semver1 = prerelease; |
483 | | - |
484 | | - // Identify numeric identifiers and pad them. |
485 | | - Assumes.True(prerelease.StartsWith("-")); |
486 | | - semver1 = "-" + NumericIdentifierRegex.Replace(semver1.Substring(1), m => string.Format(CultureInfo.InvariantCulture, paddingFormatter, int.Parse(m.Groups[1].Value))); |
487 | | - |
488 | | - semver1 = semver1.Replace('.', '-'); |
489 | | - |
490 | | - return semver1; |
491 | | - } |
492 | | - |
493 | 462 | private static int CalculateVersionHeight(string relativeRepoProjectDirectory, LibGit2Sharp.Commit headCommit, VersionOptions committedVersion, VersionOptions workingVersion) |
494 | 463 | { |
495 | 464 | var headCommitVersion = committedVersion?.Version?.Version ?? Version0; |
|
0 commit comments