1
- using System ;
2
- using System . Text . RegularExpressions ;
1
+ using System . Text . RegularExpressions ;
3
2
using LibGit2Sharp . Tests . TestHelpers ;
4
3
using Xunit ;
5
4
@@ -20,33 +19,35 @@ public void CanGetMinimumCompiledInFeatures()
20
19
public void CanRetrieveValidVersionString ( )
21
20
{
22
21
// Version string format is:
23
- // Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)
22
+ // Major.Minor.Patch[-preDateTime] -LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)
24
23
// Example output:
25
- // "0.17.0-unknown -06d772d (x86 - Threads, Https)"
24
+ // "0.17.0[-pre20170914123547]-deadcafe -06d772d (x86 - Threads, Https)"
26
25
27
26
string versionInfo = GlobalSettings . Version . ToString ( ) ;
28
27
29
28
// The GlobalSettings.Version returned string should contain :
30
- // version: '0.17.0[.198[-pre] ]' LibGit2Sharp version number.
29
+ // version: '0.17.0[-pre20170914123547 ]' LibGit2Sharp version number.
31
30
// git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash.
32
31
// git2hash: '06d772d' LibGit2 library hash.
33
32
// arch: 'x86' or 'amd64' LibGit2 target.
34
33
// git2Features: 'Threads, Ssh' LibGit2 features compiled with.
35
- string regex = @"^(?<version>\d{1,}\.\d{1,2}\.\d{1,3}(\.\d{1,5}(-pre)? )?)-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$" ;
34
+ string regex = @"^(?<version>\d{1,}\.\d{1,2}\.\d{1,3}(-(pre|dev)\d{14} )?)-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$" ;
36
35
37
36
Assert . NotNull ( versionInfo ) ;
38
37
39
38
Match regexResult = Regex . Match ( versionInfo , regex ) ;
40
39
41
40
Assert . True ( regexResult . Success , "The following version string format is enforced:" +
42
- "Major.Minor.Patch[.Build['-pre'] ]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)" ) ;
41
+ "Major.Minor.Patch[-preDateTime ]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - features)" ) ;
43
42
44
43
GroupCollection matchGroups = regexResult . Groups ;
45
44
45
+ Assert . Equal ( 8 , matchGroups . Count ) ;
46
+
46
47
// Check that all groups are valid
47
48
for ( int i = 0 ; i < matchGroups . Count ; i ++ )
48
49
{
49
- if ( i == 1 || i == 2 ) // Build number and '-pre' are optional
50
+ if ( i == 1 || i == 2 ) // '-pre' segment is optional
50
51
{
51
52
continue ;
52
53
}
0 commit comments