|
|
|
@ -188,20 +188,22 @@ public class VladAutomatic : BaseGitPackage
|
|
|
|
|
progress?.Report(new ProgressReport(1, isIndeterminate: false)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<string> DownloadPackage(string version, bool isCommitHash, IProgress<ProgressReport>? progress = null) |
|
|
|
|
public override async Task<string> DownloadPackage(string version, bool isCommitHash, |
|
|
|
|
string? branch, IProgress<ProgressReport>? progress = null) |
|
|
|
|
{ |
|
|
|
|
progress?.Report(new ProgressReport(0.1f, message: "Downloading package...", isIndeterminate: true, type: ProgressType.Download)); |
|
|
|
|
|
|
|
|
|
progress?.Report(new ProgressReport(0.1f, message: "Downloading package...", |
|
|
|
|
isIndeterminate: true, type: ProgressType.Download)); |
|
|
|
|
|
|
|
|
|
var installDir = new DirectoryPath(InstallLocation); |
|
|
|
|
installDir.Create(); |
|
|
|
|
|
|
|
|
|
await PrerequisiteHelper.RunGit( |
|
|
|
|
installDir.Parent ?? "", "clone", "https://github.com/vladmandic/automatic", installDir.Name) |
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await PrerequisiteHelper |
|
|
|
|
.RunGit(installDir.Parent ?? "", "clone", "https://github.com/vladmandic/automatic", |
|
|
|
|
installDir.Name).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
await PrerequisiteHelper.RunGit( |
|
|
|
|
InstallLocation, "checkout", version).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return version; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -244,15 +246,18 @@ public class VladAutomatic : BaseGitPackage
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
progress?.Report(new ProgressReport(0.1f, message: "Downloading package update...", |
|
|
|
|
isIndeterminate: true, type: ProgressType.Download)); |
|
|
|
|
isIndeterminate: true, type: ProgressType.Update)); |
|
|
|
|
|
|
|
|
|
var version = await GithubApi.GetAllCommits(Author, Name, installedPackage.InstalledBranch).ConfigureAwait(false); |
|
|
|
|
var latest = version?.FirstOrDefault(); |
|
|
|
|
await PrerequisiteHelper.RunGit(installedPackage.FullPath, "checkout", |
|
|
|
|
installedPackage.InstalledBranch).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
var venvRunner = new PyVenvRunner(Path.Combine(installedPackage.FullPath!, "venv")); |
|
|
|
|
venvRunner.WorkingDirectory = InstallLocation; |
|
|
|
|
venvRunner.EnvironmentVariables = SettingsManager.Settings.EnvironmentVariables; |
|
|
|
|
|
|
|
|
|
await venvRunner.CustomInstall("launch.py --upgrade --test", OnConsoleOutput) |
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
if (latest?.Sha is null) |
|
|
|
|
{ |
|
|
|
|
throw new Exception("Could not get latest version"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
@ -261,22 +266,18 @@ public class VladAutomatic : BaseGitPackage
|
|
|
|
|
.GetGitOutput(installedPackage.FullPath, "rev-parse", "HEAD") |
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
if (output.Replace(Environment.NewLine, "") == latest.Sha) |
|
|
|
|
{ |
|
|
|
|
return latest.Sha; |
|
|
|
|
} |
|
|
|
|
return output.Replace(Environment.NewLine, "").Replace("\n", ""); |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
|
Logger.Warn(e, "Could not get current git hash, continuing with update"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await PrerequisiteHelper.RunGit(installedPackage.FullPath, "pull", |
|
|
|
|
"origin", installedPackage.InstalledBranch).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
progress?.Report(new ProgressReport(1f, message: "Update Complete", isIndeterminate: false, |
|
|
|
|
type: ProgressType.Generic)); |
|
|
|
|
|
|
|
|
|
return latest.Sha; |
|
|
|
|
finally |
|
|
|
|
{ |
|
|
|
|
progress?.Report(new ProgressReport(1f, message: "Update Complete", isIndeterminate: false, |
|
|
|
|
type: ProgressType.Update)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return installedPackage.InstalledBranch; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|