|
|
@ -90,11 +90,7 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
|
|
|
|
|
|
|
|
// Version types (release or commit) |
|
|
|
// Version types (release or commit) |
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
[NotifyPropertyChangedFor( |
|
|
|
[NotifyPropertyChangedFor(nameof(ReleaseLabelText), nameof(IsReleaseMode), nameof(SelectedVersion))] |
|
|
|
nameof(ReleaseLabelText), |
|
|
|
|
|
|
|
nameof(IsReleaseMode), |
|
|
|
|
|
|
|
nameof(SelectedVersion) |
|
|
|
|
|
|
|
)] |
|
|
|
|
|
|
|
private PackageVersionType selectedVersionType = PackageVersionType.Commit; |
|
|
|
private PackageVersionType selectedVersionType = PackageVersionType.Commit; |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
@ -106,22 +102,16 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
[NotifyPropertyChangedFor(nameof(CanInstall))] |
|
|
|
[NotifyPropertyChangedFor(nameof(CanInstall))] |
|
|
|
private bool isLoading; |
|
|
|
private bool isLoading; |
|
|
|
|
|
|
|
|
|
|
|
public string ReleaseLabelText => |
|
|
|
public string ReleaseLabelText => IsReleaseMode ? Resources.Label_Version : Resources.Label_Branch; |
|
|
|
IsReleaseMode ? Resources.Label_Version : Resources.Label_Branch; |
|
|
|
|
|
|
|
public bool IsReleaseMode |
|
|
|
public bool IsReleaseMode |
|
|
|
{ |
|
|
|
{ |
|
|
|
get => SelectedVersionType == PackageVersionType.GithubRelease; |
|
|
|
get => SelectedVersionType == PackageVersionType.GithubRelease; |
|
|
|
set => |
|
|
|
set => SelectedVersionType = value ? PackageVersionType.GithubRelease : PackageVersionType.Commit; |
|
|
|
SelectedVersionType = value |
|
|
|
|
|
|
|
? PackageVersionType.GithubRelease |
|
|
|
|
|
|
|
: PackageVersionType.Commit; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
public bool IsReleaseModeAvailable => |
|
|
|
public bool IsReleaseModeAvailable => AvailableVersionTypes.HasFlag(PackageVersionType.GithubRelease); |
|
|
|
AvailableVersionTypes.HasFlag(PackageVersionType.GithubRelease); |
|
|
|
|
|
|
|
public bool ShowTorchVersionOptions => SelectedTorchVersion != TorchVersion.None; |
|
|
|
public bool ShowTorchVersionOptions => SelectedTorchVersion != TorchVersion.None; |
|
|
|
|
|
|
|
|
|
|
|
public bool CanInstall => |
|
|
|
public bool CanInstall => !string.IsNullOrWhiteSpace(InstallName) && !ShowDuplicateWarning && !IsLoading; |
|
|
|
!string.IsNullOrWhiteSpace(InstallName) && !ShowDuplicateWarning && !IsLoading; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<IPackageStep> Steps { get; set; } |
|
|
|
public IEnumerable<IPackageStep> Steps { get; set; } |
|
|
|
|
|
|
|
|
|
|
@ -254,10 +244,8 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
if (IsReleaseMode) |
|
|
|
if (IsReleaseMode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
downloadOptions.VersionTag = |
|
|
|
downloadOptions.VersionTag = |
|
|
|
SelectedVersion?.TagName |
|
|
|
SelectedVersion?.TagName ?? throw new NullReferenceException("Selected version is null"); |
|
|
|
?? throw new NullReferenceException("Selected version is null"); |
|
|
|
downloadOptions.IsLatest = AvailableVersions?.First().TagName == downloadOptions.VersionTag; |
|
|
|
downloadOptions.IsLatest = |
|
|
|
|
|
|
|
AvailableVersions?.First().TagName == downloadOptions.VersionTag; |
|
|
|
|
|
|
|
downloadOptions.IsPrerelease = SelectedVersion.IsPrerelease; |
|
|
|
downloadOptions.IsPrerelease = SelectedVersion.IsPrerelease; |
|
|
|
|
|
|
|
|
|
|
|
installedVersion.InstalledReleaseVersion = downloadOptions.VersionTag; |
|
|
|
installedVersion.InstalledReleaseVersion = downloadOptions.VersionTag; |
|
|
@ -268,21 +256,15 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
downloadOptions.CommitHash = |
|
|
|
downloadOptions.CommitHash = |
|
|
|
SelectedCommit?.Sha ?? throw new NullReferenceException("Selected commit is null"); |
|
|
|
SelectedCommit?.Sha ?? throw new NullReferenceException("Selected commit is null"); |
|
|
|
downloadOptions.BranchName = |
|
|
|
downloadOptions.BranchName = |
|
|
|
SelectedVersion?.TagName |
|
|
|
SelectedVersion?.TagName ?? throw new NullReferenceException("Selected version is null"); |
|
|
|
?? throw new NullReferenceException("Selected version is null"); |
|
|
|
|
|
|
|
downloadOptions.IsLatest = AvailableCommits?.First().Sha == SelectedCommit.Sha; |
|
|
|
downloadOptions.IsLatest = AvailableCommits?.First().Sha == SelectedCommit.Sha; |
|
|
|
|
|
|
|
|
|
|
|
installedVersion.InstalledBranch = |
|
|
|
installedVersion.InstalledBranch = |
|
|
|
SelectedVersion?.TagName |
|
|
|
SelectedVersion?.TagName ?? throw new NullReferenceException("Selected version is null"); |
|
|
|
?? throw new NullReferenceException("Selected version is null"); |
|
|
|
|
|
|
|
installedVersion.InstalledCommitSha = downloadOptions.CommitHash; |
|
|
|
installedVersion.InstalledCommitSha = downloadOptions.CommitHash; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var downloadStep = new DownloadPackageVersionStep( |
|
|
|
var downloadStep = new DownloadPackageVersionStep(SelectedPackage, installLocation, downloadOptions); |
|
|
|
SelectedPackage, |
|
|
|
|
|
|
|
installLocation, |
|
|
|
|
|
|
|
downloadOptions |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
var installStep = new InstallPackageStep( |
|
|
|
var installStep = new InstallPackageStep( |
|
|
|
SelectedPackage, |
|
|
|
SelectedPackage, |
|
|
|
SelectedTorchVersion, |
|
|
|
SelectedTorchVersion, |
|
|
@ -351,9 +333,7 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// First try to find the package-defined main branch |
|
|
|
// First try to find the package-defined main branch |
|
|
|
var version = AvailableVersions.FirstOrDefault( |
|
|
|
var version = AvailableVersions.FirstOrDefault(x => x.TagName == SelectedPackage.MainBranch); |
|
|
|
x => x.TagName == SelectedPackage.MainBranch |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
// If not found, try main |
|
|
|
// If not found, try main |
|
|
|
version ??= AvailableVersions.FirstOrDefault(x => x.TagName == "main"); |
|
|
|
version ??= AvailableVersions.FirstOrDefault(x => x.TagName == "main"); |
|
|
|
|
|
|
|
|
|
|
@ -406,8 +386,8 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
if (SelectedPackage is null || Design.IsDesignMode) |
|
|
|
if (SelectedPackage is null || Design.IsDesignMode) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
Dispatcher.UIThread |
|
|
|
Dispatcher |
|
|
|
.InvokeAsync(async () => |
|
|
|
.UIThread.InvokeAsync(async () => |
|
|
|
{ |
|
|
|
{ |
|
|
|
logger.LogDebug($"Release mode: {IsReleaseMode}"); |
|
|
|
logger.LogDebug($"Release mode: {IsReleaseMode}"); |
|
|
|
var versionOptions = await SelectedPackage.GetAllVersionOptions(); |
|
|
|
var versionOptions = await SelectedPackage.GetAllVersionOptions(); |
|
|
@ -425,9 +405,7 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
|
|
|
|
|
|
|
|
if (!IsReleaseMode) |
|
|
|
if (!IsReleaseMode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var commits = ( |
|
|
|
var commits = (await SelectedPackage.GetAllCommits(SelectedVersion.TagName))?.ToList(); |
|
|
|
await SelectedPackage.GetAllCommits(SelectedVersion.TagName) |
|
|
|
|
|
|
|
)?.ToList(); |
|
|
|
|
|
|
|
if (commits is null || commits.Count == 0) |
|
|
|
if (commits is null || commits.Count == 0) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
@ -495,7 +473,11 @@ public partial class InstallerViewModel : ContentDialogViewModelBase |
|
|
|
Dispatcher.UIThread.Post(() => |
|
|
|
Dispatcher.UIThread.Post(() => |
|
|
|
{ |
|
|
|
{ |
|
|
|
AvailableCommits = new ObservableCollection<GitCommit>(hashes); |
|
|
|
AvailableCommits = new ObservableCollection<GitCommit>(hashes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (AvailableCommits.Count > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
SelectedCommit = AvailableCommits[0]; |
|
|
|
SelectedCommit = AvailableCommits[0]; |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
catch (Exception e) |
|
|
|