Skip to content

Commit 7cbbefc

Browse files
author
Pascal van Buijtene
committed
Fix reported version with annotated tag
1 parent e75b818 commit 7cbbefc

File tree

7 files changed

+8
-75
lines changed

7 files changed

+8
-75
lines changed

Diff for: build.ps1

-67
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,6 @@ Function Write-Info {
2020
}
2121
}
2222

23-
Function Patch-VersionInfo {
24-
Param(
25-
[Parameter(Mandatory=$true)]
26-
[string]$versionInfoFilePath,
27-
[Parameter(Mandatory=$true)]
28-
[string]$version,
29-
[Parameter(Mandatory=$true)]
30-
[string]$branch,
31-
[Parameter(Mandatory=$true)]
32-
[string]$commitHash,
33-
[Parameter(Mandatory=$true)]
34-
[string]$timestamp
35-
36-
)
37-
Process {
38-
$newVersion = 'public static readonly string Version = "' + $version + '";'
39-
$newBranch = 'public static readonly string Branch = "' + $branch + '";'
40-
$newCommitHash = 'public static readonly string Hashtag = "' + $commitHash + '";'
41-
$newTimestamp = 'public static readonly string Timestamp = "' + $timestamp + '";'
42-
43-
$versionPattern = 'public static readonly string Version = ".*";'
44-
$branchPattern = 'public static readonly string Branch = ".*";'
45-
$commitHashPattern = 'public static readonly string Hashtag = ".*";'
46-
$timestampPattern = 'public static readonly string Timestamp = ".*";'
47-
48-
$edited = (Get-Content $versionInfoFilePath) | ForEach-Object {
49-
% {$_ -replace "\/\*+.*\*+\/", "" } |
50-
% {$_ -replace "\/\/+.*$", "" } |
51-
% {$_ -replace "\/\*+.*$", "" } |
52-
% {$_ -replace "^.*\*+\/\b*$", "" } |
53-
% {$_ -replace $versionPattern, $newVersion} |
54-
% {$_ -replace $branchPattern, $newBranch} |
55-
% {$_ -replace $commitHashPattern, $newCommitHash } |
56-
% {$_ -replace $timestampPattern, $newTimestamp}
57-
}
58-
59-
Set-Content -Path $versionInfoFilePath -Value $edited
60-
}
61-
}
62-
6323
#Borrowed from psake
6424
Function Exec
6525
{
@@ -75,29 +35,6 @@ Function Exec
7535
}
7636
}
7737

78-
Function Get-GitCommitHash
79-
{
80-
$lastCommitLog = Exec { git log --max-count=1 --pretty=format:%H HEAD } "Cannot execute git log. Ensure that the current directory is a git repository and that git is available on PATH."
81-
return $lastCommitLog
82-
}
83-
84-
Function Get-GitTimestamp
85-
{
86-
$lastCommitLog = Exec { git log --max-count=1 --pretty=format:%aD HEAD } "Cannot execute git log. Ensure that the current directory is a git repository and that git is available on PATH."
87-
return $lastCommitLog
88-
}
89-
90-
Function Get-GitBranchOrTag
91-
{
92-
$revParse = Exec { git rev-parse --abbrev-ref HEAD } "Cannot execute git rev-parse. Ensure that the current directory is a git repository and that git is available on PATH."
93-
if ($revParse -ne "HEAD") {
94-
return $revParse
95-
}
96-
97-
$describeTags = Exec { git describe --tags } "Cannot execute git describe. Ensure that the current directory is a git repository and that git is available on PATH."
98-
return $describeTags
99-
}
100-
10138
Function Start-Build{
10239
#Make compatible with Powershell 2
10340
if(!$PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent }
@@ -145,10 +82,6 @@ Function Start-Build{
14582
#Build Event Store (Patch AssemblyInfo, Build, Revert AssemblyInfo)
14683
Remove-Item -Force -Recurse $binDirectory -ErrorAction SilentlyContinue > $null
14784

148-
$commitHash = Get-GitCommitHash
149-
$timestamp = Get-GitTimestamp
150-
$branchName = Get-GitBranchOrTag
151-
15285
$versionInfoFile = Resolve-Path (Join-Path $srcDirectory (Join-Path "EventStore.Common" (Join-Path "Utils" "VersionInfo.cs"))) -Relative
15386
try {
15487
Exec { dotnet build -c $configuration /p:Version=$Version /p:Platform=x64 $eventStoreSolution }

Diff for: src/EventStore.ClusterNode/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static async Task<int> Main(string[] args) {
6464
}
6565

6666
Log.Information("\n{description,-25} {version} ({branch}/{hashtag}, {timestamp})", "ES VERSION:",
67-
VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp);
67+
VersionInfo.Version, VersionInfo.Tag, VersionInfo.Hashtag, VersionInfo.Timestamp);
6868
Log.Information("{description,-25} {osArchitecture} ", "OS ARCHITECTURE:",
6969
RuntimeInformation.OSArchitecture);
7070
Log.Information("{description,-25} {osFlavor} ({osVersion})", "OS:", OS.OsFlavor,

Diff for: src/EventStore.Common/EventStore.Common.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
16-
<PackageReference Include="GitInfo" Version="2.0.26">
16+
<PackageReference Include="GitInfo" Version="3.3.3">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1919
</PackageReference>

Diff for: src/EventStore.Common/Utils/VersionInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public static class VersionInfo {
88
public static string Version => typeof(VersionInfo).Assembly
99
.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version ?? DefaultVersion;
1010

11-
public static string Branch => ThisAssembly.Git.Branch;
11+
public static string Tag => ThisAssembly.Git.Tag;
1212
public static string Hashtag => ThisAssembly.Git.Commit;
13-
public static readonly string Timestamp = "Unknown";
13+
public static readonly string Timestamp = ThisAssembly.Git.CommitDate;
1414

15-
public static string Text => $"EventStoreDB version {Version} ({Branch}/{Hashtag}, {Timestamp})";
15+
public static string Text => $"EventStoreDB version {Version} ({Tag}/{Hashtag}, {Timestamp})";
1616
}
1717
}

Diff for: src/EventStore.Core.Tests/Helpers/MiniClusterNode.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public MiniClusterNode(string pathname, int debugIndex, IPEndPoint internalTcp,
162162
Log.Information(
163163
"\n{0,-25} {1} ({2}/{3}, {4})\n" + "{5,-25} {6} ({7})\n" + "{8,-25} {9} ({10}-bit)\n"
164164
+ "{11,-25} {12}\n" + "{13,-25} {14}\n" + "{15,-25} {16}\n" + "{17,-25} {18}\n\n",
165-
"ES VERSION:", VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp,
165+
"ES VERSION:", VersionInfo.Version, VersionInfo.Tag, VersionInfo.Hashtag, VersionInfo.Timestamp,
166166
"OS:", OS.OsFlavor, Environment.OSVersion, "RUNTIME:", OS.GetRuntimeVersion(),
167167
Marshal.SizeOf(typeof(IntPtr)) * 8, "GC:",
168168
GC.MaxGeneration == 0

Diff for: src/EventStore.Core.Tests/Helpers/MiniNode.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public MiniNode(string pathname,
146146
+ "{13,-25} {14}\n"
147147
+ "{15,-25} {16}\n"
148148
+ "{17,-25} {18}\n\n",
149-
"ES VERSION:", VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp,
149+
"ES VERSION:", VersionInfo.Version, VersionInfo.Tag, VersionInfo.Hashtag, VersionInfo.Timestamp,
150150
"OS:", OS.OsFlavor, Environment.OSVersion,
151151
"RUNTIME:", OS.GetRuntimeVersion(), Marshal.SizeOf(typeof(IntPtr)) * 8,
152152
"GC:",

Diff for: src/EventStore.Core.Tests/TestsInitFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private void LogEnvironmentInfo() {
2121
+ "{5,-25} {6} ({7})\n"
2222
+ "{8,-25} {9} ({10}-bit)\n"
2323
+ "{11,-25} {12}\n\n",
24-
"ES VERSION:", VersionInfo.Version, VersionInfo.Branch, VersionInfo.Hashtag, VersionInfo.Timestamp,
24+
"ES VERSION:", VersionInfo.Version, VersionInfo.Tag, VersionInfo.Hashtag, VersionInfo.Timestamp,
2525
"OS:", OS.OsFlavor, Environment.OSVersion,
2626
"RUNTIME:", OS.GetRuntimeVersion(), Marshal.SizeOf(typeof(IntPtr)) * 8,
2727
"GC:",

0 commit comments

Comments
 (0)