public static void Menu_DownloadLatestDugite() { LogHelper.LogAdapter = new UnityLogAdapter(); var extensionInstallPath = Application.dataPath.ToSPath().Parent; var unityEnv = TheEnvironment.instance.Environment; var env = new ApplicationEnvironment(unityEnv); env.Initialize(extensionInstallPath, unityEnv); var platform = new Platform(env); platform.Initialize(); env.InitializeRepository(); var installer = new GitInstaller.GitInstallDetails(env.RepositoryPath, env); var manifest = DugiteReleaseManifest.Load(platform.TaskManager, installer.GitManifest, installer.GitManifestFeed, platform.Environment); var cts = new CancellationTokenSource(); var downloader = new Downloader(platform.TaskManager, cts.Token); var downloadPath = env.RepositoryPath.Combine("downloads"); foreach (var asset in manifest.Assets) { downloadPath.Combine(asset.Url.Filename).DeleteIfExists(); downloader.QueueDownload(asset.Url, downloadPath, retryCount: 3); } downloader.Progress(p => { platform.TaskManager.RunInUI(() => { if (EditorUtility.DisplayCancelableProgressBar(p.Message, p.InnerProgress?.InnerProgress?.Message ?? p.InnerProgress?.Message ?? p.Message, p.Percentage)) { cts.Cancel(); } }); }).FinallyInUI((success, ex) => { EditorUtility.ClearProgressBar(); if (success) { EditorUtility.DisplayDialog("Download done", downloadPath, "Ok"); } else { EditorUtility.DisplayDialog("Error!", ex.GetExceptionMessageShort(), "Ok"); } }).Start(); }
public static void Menu_DownloadLatestDugite() { LogHelper.LogAdapter = new UnityLogAdapter(); var unityAssetsPath = Application.dataPath; var unityApplication = EditorApplication.applicationPath; var unityApplicationContents = EditorApplication.applicationContentsPath; var extensionInstallPath = Application.dataPath.ToNPath().Parent; var unityVersion = Application.unityVersion; var env = new DefaultEnvironment(); env.Initialize(unityVersion, extensionInstallPath, unityApplication.ToNPath(), unityApplicationContents.ToNPath(), unityAssetsPath.ToNPath()); env.InitializeRepository(); TaskManager.Instance.Initialize(new UnityUIThreadSynchronizationContext()); var installer = new GitInstaller.GitInstallDetails(env.RepositoryPath, env); var manifest = DugiteReleaseManifest.Load(installer.GitManifest, GitInstaller.GitInstallDetails.GitPackageFeed, env); var downloader = new Downloader(); var downloadPath = env.RepositoryPath.Combine("downloads"); foreach (var asset in manifest.Assets) { downloadPath.Combine(asset.Url.Filename).DeleteIfExists(); downloader.QueueDownload(asset.Url, downloadPath, retryCount: 3); } downloader.Progress(p => { TaskManager.Instance.RunInUI(() => { if (EditorUtility.DisplayCancelableProgressBar(p.Message, p.InnerProgress?.InnerProgress?.Message ?? p.InnerProgress?.Message ?? p.Message, p.Percentage)) { downloader.Cancel(); } }); }).FinallyInUI((success, ex) => { EditorUtility.ClearProgressBar(); if (success) { EditorUtility.DisplayDialog("Download done", downloadPath, "Ok"); } else { EditorUtility.DisplayDialog("Error!", ex.GetExceptionMessageOnly(), "Ok"); } }).Start(); }
protected void SetupGit(NPath pathToSetupGitInto, string testName) { var installDetails = new GitInstaller.GitInstallDetails(pathToSetupGitInto, Environment); var state = installDetails.GetDefaults(); Environment.GitInstallationState = state; GitClient = new GitClient(Environment, ProcessManager, TaskManager.Token); if (installDetails.GitExecutablePath.FileExists() && installDetails.GitLfsExecutablePath.FileExists()) { return; } var key = installDetails.GitManifest.FileNameWithoutExtension + "_updatelastCheckTime"; Environment.UserSettings.Set(key, DateTimeOffset.Now); var localCache = TestLocation.Combine("Resources"); localCache.CopyFiles(pathToSetupGitInto, true); // skip checking for updates state.GitPackage = DugiteReleaseManifest.Load(installDetails.GitManifest, GitInstaller.GitInstallDetails.GitPackageFeed, Environment); var asset = state.GitPackage.DugitePackage; state.GitZipPath = installDetails.ZipPath.Combine(asset.Name); installDetails.GitInstallationPath.DeleteIfExists(); state.GitZipPath.EnsureParentDirectoryExists(); var gitExtractPath = TestBasePath.Combine("setup", "git_zip_extract_zip_paths").EnsureDirectoryExists(); var source = new UnzipTask(TaskManager.Token, state.GitZipPath, gitExtractPath, null, Environment.FileSystem) .RunSynchronously(); installDetails.GitInstallationPath.EnsureParentDirectoryExists(); source.Move(installDetails.GitInstallationPath); }
public void InstallTestGit() { var installDetails = Environment.GitDefaultInstallation; var state = installDetails.GetDefaults(); Environment.GitInstallationState = state; if (installDetails.GitExecutablePath.FileExists() && installDetails.GitLfsExecutablePath.FileExists()) { return; } var key = installDetails.GitManifest.FileNameWithoutExtension + "_updatelastCheckTime"; Environment.UserSettings.Set(key, DateTimeOffset.Now); var localCache = SourceDirectory.Combine("files/git"); localCache.CopyFiles(installDetails.ZipPath.Parent, true); // skip checking for updates state.GitPackage = DugiteReleaseManifest.Load(TaskManager, installDetails.GitManifest, GitInstaller.GitInstallDetails.ManifestFeed, Environment); var asset = state.GitPackage.DugitePackage; state.GitZipPath = installDetails.ZipPath.Combine(asset.Name); installDetails.GitInstallationPath.DeleteIfExists(); state.GitZipPath.EnsureParentDirectoryExists(); var gitExtractPath = TestPath.Combine("setup", "git_zip_extract_zip_paths").EnsureDirectoryExists(); var source = new UnzipTask(TaskManager, state.GitZipPath, gitExtractPath) .RunSynchronously(); installDetails.GitInstallationPath.EnsureParentDirectoryExists(); source.Move(installDetails.GitInstallationPath); }