Browse Source

Prioritize master branch over main branch

pull/55/head
Ionite 1 year ago
parent
commit
ee5ad04bf6
No known key found for this signature in database
  1. 28
      StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs

28
StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs

@ -127,11 +127,10 @@ public partial class InstallerViewModel : ContentDialogViewModelBase
TagName = b.Name,
ReleaseNotesMarkdown = b.Commit.Label
}));
SelectedVersion = AvailableVersions.FirstOrDefault(x =>
x.TagName.ToLowerInvariant() is "master" or "main") ?? AvailableVersions[0];
UpdateSelectedVersionToLatestMain();
}
ReleaseNotes = SelectedVersion.ReleaseNotesMarkdown;
ReleaseNotes = SelectedVersion?.ReleaseNotesMarkdown;
}
catch (Exception e)
{
@ -249,6 +248,26 @@ public partial class InstallerViewModel : ContentDialogViewModelBase
}
}
private void UpdateSelectedVersionToLatestMain()
{
if (AvailableVersions is null)
{
SelectedVersion = null;
}
else
{
// First try to find master
var version = AvailableVersions.FirstOrDefault(x => x.TagName == "master");
// If not found, try main
version ??= AvailableVersions.FirstOrDefault(x => x.TagName == "main");
// If still not found, just use the first one
version ??= AvailableVersions[0];
SelectedVersion = version;
}
}
private static string GetDisplayVersion(string version, string? branch)
{
return branch == null ? version : $"{branch}@{version[..7]}";
@ -367,8 +386,7 @@ public partial class InstallerViewModel : ContentDialogViewModelBase
AvailableCommits = new ObservableCollection<GitCommit>(commits);
SelectedCommit = AvailableCommits[0];
SelectedVersion = AvailableVersions?.FirstOrDefault(packageVersion =>
packageVersion.TagName.ToLowerInvariant() is "master" or "main");
UpdateSelectedVersionToLatestMain();
}
InstallName = SelectedPackage.DisplayName;

Loading…
Cancel
Save