Skip to content

Fix handling of not yet released alphas #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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