Skip to content

Commit b924152

Browse files
committed
Make version comply to SemVer
1 parent e137a8e commit b924152

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

LibGit2Sharp.Tests/GlobalSettingsFixture.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Text.RegularExpressions;
1+
using System.Text.RegularExpressions;
32
using LibGit2Sharp.Tests.TestHelpers;
43
using Xunit;
54

@@ -20,33 +19,35 @@ public void CanGetMinimumCompiledInFeatures()
2019
public void CanRetrieveValidVersionString()
2120
{
2221
// 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)
2423
// Example output:
25-
// "0.17.0-unknown-06d772d (x86 - Threads, Https)"
24+
// "0.17.0[-pre20170914123547]-deadcafe-06d772d (x86 - Threads, Https)"
2625

2726
string versionInfo = GlobalSettings.Version.ToString();
2827

2928
// 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.
3130
// git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash.
3231
// git2hash: '06d772d' LibGit2 library hash.
3332
// arch: 'x86' or 'amd64' LibGit2 target.
3433
// 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+)*)\)$";
3635

3736
Assert.NotNull(versionInfo);
3837

3938
Match regexResult = Regex.Match(versionInfo, regex);
4039

4140
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)");
4342

4443
GroupCollection matchGroups = regexResult.Groups;
4544

45+
Assert.Equal(8, matchGroups.Count);
46+
4647
// Check that all groups are valid
4748
for (int i = 0; i < matchGroups.Count; i++)
4849
{
49-
if (i == 1 || i == 2) // Build number and '-pre' are optional
50+
if (i == 1 || i == 2) // '-pre' segment is optional
5051
{
5152
continue;
5253
}

LibGit2Sharp/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
// by using the '*' as shown below:
4343
// [assembly: AssemblyVersion("1.0.*")]
4444

45-
[assembly: AssemblyVersion("0.21.0")]
46-
[assembly: AssemblyFileVersion("0.21.0")]
47-
[assembly: AssemblyInformationalVersion("0.21.0")]
45+
[assembly: AssemblyVersion("0.22.0")]
46+
[assembly: AssemblyFileVersion("0.22.0")]
47+
[assembly: AssemblyInformationalVersion("0.22.0-dev00000000000000")]

appveyor.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '0.21.0.{build}'
1+
version: '{build}'
22

33
branches:
44
only:
@@ -10,6 +10,7 @@ skip_tags: true
1010
clone_folder: C:\projects\libgit2sharp
1111

1212
environment:
13+
version : 0.22.0
1314
matrix:
1415
- xunit_runner: xunit.console.clr4.exe
1516
Arch: 64
@@ -22,15 +23,17 @@ matrix:
2223
install:
2324
- ps: |
2425
Write-Host "Commit being built = $($Env:APPVEYOR_REPO_COMMIT)"
25-
Write-Host "Current build version = $($Env:APPVEYOR_BUILD_VERSION)"
26+
Write-Host "Current build version = $($Env:VERSION)"
2627
Write-Host "Target branch = $($Env:APPVEYOR_REPO_BRANCH)"
2728
Write-Host "Is a Pull Request = $($Env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null)"
29+
$BuildDate = (Get-Date).ToUniversalTime().ToString("yyyyMMddHHmmss")
30+
Write-Host "Build UTC date = $BuildDate"
2831
$VersionSuffix = ""
2932
If ($Env:APPVEYOR_REPO_BRANCH -ne "master")
3033
{
31-
$VersionSuffix = "-pre"
34+
$VersionSuffix = "-pre$BuildDate"
3235
}
33-
$Version = "$($Env:APPVEYOR_BUILD_VERSION)$($VersionSuffix)"
36+
$Version = "$($Env:VERSION)$($VersionSuffix)"
3437
$Env:ASSEMBLY_INFORMATIONAL_VERSION = $Version
3538
Write-Host "Assembly informational version = $($Env:ASSEMBLY_INFORMATIONAL_VERSION)"
3639
$ShouldPublishNugetArtifact = "$($env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null)"
@@ -40,8 +43,8 @@ install:
4043
assembly_info:
4144
patch: true
4245
file: LibGit2Sharp\Properties\AssemblyInfo.cs
43-
assembly_version: '{version}'
44-
assembly_file_version: '{version}'
46+
assembly_version: '$(VERSION)'
47+
assembly_file_version: '$(VERSION)'
4548
assembly_informational_version: '$(ASSEMBLY_INFORMATIONAL_VERSION)'
4649

4750
cache:

0 commit comments

Comments
 (0)