Skip to content

Commit

Permalink
Fix handling of not yet released alphas (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon authored Sep 14, 2021
1 parent 0a2d3e6 commit e857ee8
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Elastic.Stack.ArtifactsApi/ElasticVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ public Artifact Artifact(Product product)
/// </summary>
public static ElasticVersion From(string managedVersionString)
{
ArtifactBuildState GetReleaseState(string s)
{
return s.EndsWith("-SNAPSHOT")
ArtifactBuildState GetReleaseState(string s) => s.EndsWith("-SNAPSHOT")
? ArtifactBuildState.Snapshot
: ApiResolver.IsReleasedVersion(s)
? ArtifactBuildState.Released
: ArtifactBuildState.BuildCandidate;
}
// When the version is not yet released but contains the alpha label, we treat it in the same way as snapshots so it is resolved correctly
: s.IndexOf("-alpha", StringComparison.OrdinalIgnoreCase) >= 0
? ArtifactBuildState.Snapshot
: ArtifactBuildState.BuildCandidate;

if (string.IsNullOrWhiteSpace(managedVersionString))
return null;
Expand All @@ -88,10 +88,7 @@ ArtifactBuildState GetReleaseState(string s)
if (state == ArtifactBuildState.BuildCandidate)
buildHash = ApiResolver.LatestBuildHash(version);
break;
// When the version is not yet released but contains the alpha label, we treat it in the same way as snapshots so it is resolved correctly
case { } _ when managedVersionString.EndsWith("-snapshot", StringComparison.OrdinalIgnoreCase)
|| state != ArtifactBuildState.Released &&
managedVersionString.IndexOf("-alpha", StringComparison.OrdinalIgnoreCase) >= 0:
case { } _ when managedVersionString.EndsWith("-snapshot", StringComparison.OrdinalIgnoreCase):
state = ArtifactBuildState.Snapshot;
break;
case { } _ when TryParseBuildCandidate(managedVersionString, out var v, out buildHash):
Expand Down

0 comments on commit e857ee8

Please sign in to comment.