diff options
author | nulltoken <emeric.fermas@gmail.com> | 2015-02-03 18:47:14 +0300 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2015-02-06 14:58:16 +0300 |
commit | b924152b08382b95e76bf61dbb250947be631077 (patch) | |
tree | f928f8fecf59203441314330300518625abc0428 /LibGit2Sharp.Tests | |
parent | e137a8eb37b52c56ee81828af553f9c2d845ef00 (diff) |
Make version comply to SemVer
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/GlobalSettingsFixture.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs index 28d0b12c..20038cb1 100644 --- a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs +++ b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs @@ -1,5 +1,4 @@ -using System; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using LibGit2Sharp.Tests.TestHelpers; using Xunit; @@ -20,33 +19,35 @@ namespace LibGit2Sharp.Tests public void CanRetrieveValidVersionString() { // Version string format is: - // Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features) + // Major.Minor.Patch[-preDateTime]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features) // Example output: - // "0.17.0-unknown-06d772d (x86 - Threads, Https)" + // "0.17.0[-pre20170914123547]-deadcafe-06d772d (x86 - Threads, Https)" string versionInfo = GlobalSettings.Version.ToString(); // The GlobalSettings.Version returned string should contain : - // version: '0.17.0[.198[-pre]]' LibGit2Sharp version number. + // version: '0.17.0[-pre20170914123547]' LibGit2Sharp version number. // git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash. // git2hash: '06d772d' LibGit2 library hash. // arch: 'x86' or 'amd64' LibGit2 target. // git2Features: 'Threads, Ssh' LibGit2 features compiled with. - string regex = @"^(?<version>\d{1,}\.\d{1,2}\.\d{1,3}(\.\d{1,5}(-pre)?)?)-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$"; + string regex = @"^(?<version>\d{1,}\.\d{1,2}\.\d{1,3}(-(pre|dev)\d{14})?)-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$"; Assert.NotNull(versionInfo); Match regexResult = Regex.Match(versionInfo, regex); Assert.True(regexResult.Success, "The following version string format is enforced:" + - "Major.Minor.Patch[.Build['-pre']]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)"); + "Major.Minor.Patch[-preDateTime]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)"); GroupCollection matchGroups = regexResult.Groups; + Assert.Equal(8, matchGroups.Count); + // Check that all groups are valid for (int i = 0; i < matchGroups.Count; i++) { - if (i == 1 || i == 2) // Build number and '-pre' are optional + if (i == 1 || i == 2) // '-pre' segment is optional { continue; } |