Skip to content

Commit

Permalink
Update GetVersion to account pre-release tag
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Feb 14, 2024
1 parent 05f64f5 commit e4c580d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using Ductus.FluentDocker.Builders;
using Ductus.FluentDocker.Extensions;
using Ductus.FluentDocker.Model.Builders;
Expand Down Expand Up @@ -101,6 +102,7 @@ public ValueTask DisposeAsync() {

static Version GetVersion() {
const string versionPrefix = "EventStoreDB version";
var versionRegex = new Regex(@"\d+(\.\d+)*", RegexOptions.Compiled);

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
using var eventstore = new Builder().UseContainer()
Expand All @@ -111,9 +113,11 @@ static Version GetVersion() {

using var log = eventstore.Logs(true, cts.Token);
foreach (var line in log.ReadToEnd())
if (line.StartsWith(versionPrefix) &&
Version.TryParse(line[(versionPrefix.Length + 1)..].Split(' ')[0], out var version))
return version;
if (line.StartsWith(versionPrefix)) {
var versionMatch = versionRegex.Match(line);
if (versionMatch.Success && Version.TryParse(versionMatch.Value, out var version))
return version;
}

throw new InvalidOperationException("Could not determine server version.");
}
Expand Down

0 comments on commit e4c580d

Please sign in to comment.