private GitInstallationState FindGitLfs(GitInstallationState state) { if (!state.GitLfsIsValid) { var gitLfsPath = new FindExecTask("git-lfs", cancellationToken) .Configure(processManager, dontSetupGit: true) .Catch(e => true) .RunSynchronously(); state.GitLfsExecutablePath = gitLfsPath; state = ValidateGitLfsVersion(state); if (state.GitLfsIsValid) { state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent; } } return(state); }
private GitInstallationState FindGit(GitInstallationState state) { if (!state.GitIsValid) { var gitPath = new FindExecTask("git", cancellationToken) .Configure(processManager, dontSetupGit: true) .Catch(e => true) .RunWithReturn(true); state.GitExecutablePath = gitPath; state = ValidateGitVersion(state); if (state.GitIsValid) { state.GitInstallationPath = gitPath.Parent.Parent; } } return(state); }
public void Run(bool firstRun) { Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory); var octorunScriptPath = Environment.UserCachePath.Combine("octorun", "src", "bin", "app.js"); Logger.Trace("Using octorunScriptPath: {0}", octorunScriptPath); var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath(); if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists()) // we have a git path { Logger.Trace("Using git install path from settings: {0}", gitExecutablePath); InitializeEnvironment(gitExecutablePath.Value, octorunScriptPath); } else // we need to go find git { Logger.Trace("No git path found in settings"); var initEnvironmentTask = new ActionTask <NPath>(CancellationToken, (_, path) => InitializeEnvironment(path, octorunScriptPath)) { Affinity = TaskAffinity.UI }; var findExecTask = new FindExecTask("git", CancellationToken) .FinallyInUI((b, ex, path) => { if (b && path.IsInitialized) { Logger.Trace("FindExecTask Success: {0}", path); InitializeEnvironment(path, octorunScriptPath); } else { Logger.Warning("FindExecTask Failure"); Logger.Error("Git not found"); } }); var installDetails = new GitInstallDetails(Environment.UserCachePath, true); var gitInstaller = new GitInstaller(Environment, CancellationToken, installDetails); // if successful, continue with environment initialization, otherwise try to find an existing git installation gitInstaller.SetupGitIfNeeded(initEnvironmentTask, findExecTask); } }
public void Run(bool firstRun) { Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory); var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath(); if (gitExecutablePath != null && gitExecutablePath.FileExists()) // we have a git path { Logger.Trace("Using git install path from settings: {0}", gitExecutablePath); InitializeEnvironment(gitExecutablePath); } else // we need to go find git { Logger.Trace("No git path found in settings"); var initEnvironmentTask = new ActionTask <NPath>(CancellationToken, (b, path) => InitializeEnvironment(path)) { Affinity = TaskAffinity.UI }; var findExecTask = new FindExecTask("git", CancellationToken) .FinallyInUI((b, ex, path) => { if (b && path != null) { Logger.Trace("FindExecTask Success: {0}", path); InitializeEnvironment(gitExecutablePath); } else { Logger.Warning("FindExecTask Failure"); Logger.Error("Git not found"); } }); var applicationDataPath = Environment.GetSpecialFolder(System.Environment.SpecialFolder.LocalApplicationData).ToNPath(); var installDetails = new GitInstallDetails(applicationDataPath, true); var gitInstaller = new GitInstaller(Environment, CancellationToken, installDetails); // if successful, continue with environment initialization, otherwise try to find an existing git installation gitInstaller.SetupGitIfNeeded(initEnvironmentTask, findExecTask); } }
public ITask <NPath> SetupGitIfNeeded() { //Logger.Trace("SetupGitIfNeeded"); installationTask = new FuncTask <NPath, NPath>(cancellationToken, (success, path) => { return(path); }) { Name = "Git Installation - Complete" }; installationTask.OnStart += thisTask => thisTask.UpdateProgress(0, 100); installationTask.OnEnd += (thisTask, result, success, exception) => thisTask.UpdateProgress(100, 100); ITask <NPath> startTask = null; if (!environment.IsWindows) { startTask = new FindExecTask("git", cancellationToken) .Configure(processManager); // we should doublecheck that system git is usable here installationState = new GitInstallationState { GitIsValid = true, GitLfsIsValid = true }; } else { startTask = new FuncTask <NPath>(cancellationToken, () => { installationState = VerifyGitInstallation(); if (!installationState.GitIsValid && !installationState.GitLfsIsValid) { installationState = GrabZipFromResources(installationState); } else { Logger.Trace("SetupGitIfNeeded: Skipped"); } return(installDetails.GitExecutablePath); }) { Name = "Git Installation - Extract" }; } startTask.OnEnd += (thisTask, path, success, exception) => { if (!installationState.GitIsValid && !installationState.GitLfsIsValid) { if (!installationState.GitZipExists || !installationState.GitLfsZipExists) { thisTask = thisTask.Then(CreateDownloadTask(installationState)); } thisTask = thisTask.Then(ExtractPortableGit(installationState)); } thisTask.Then(installationTask); }; return(startTask); }
public ITask <GitInstallationState> SetupGitIfNeeded() { //Logger.Trace("SetupGitIfNeeded"); GitInstallationState installationState = new GitInstallationState(); installationTask = new FuncTask <GitInstallationState, GitInstallationState>(cancellationToken, (success, path) => path) { Name = "Git Installation - Complete" }; installationTask.OnStart += thisTask => thisTask.UpdateProgress(0, 100); installationTask.OnEnd += (thisTask, result, success, exception) => thisTask.UpdateProgress(100, 100); ITask <GitInstallationState> startTask = null; if (!environment.IsWindows) { var findTask = new FindExecTask("git", cancellationToken) .Configure(processManager, dontSetupGit: true) .Catch(e => true); findTask.OnEnd += (thisTask, path, success, exception) => { // we should doublecheck that system git is usable here installationState.GitIsValid = success; if (success) { installationState.GitExecutablePath = path; installationState.GitInstallationPath = path.Resolve().Parent.Parent; } }; findTask.Then(new FindExecTask("git-lfs", cancellationToken) .Configure(processManager, dontSetupGit: true)) .Catch(e => true); findTask.OnEnd += (thisTask, path, success, exception) => { installationState.GitLfsIsValid = success; if (success) { // we should doublecheck that system git is usable here installationState.GitLfsExecutablePath = path; installationState.GitLfsInstallationPath = path.Resolve().Parent.Parent; } }; startTask = findTask.Then(s => installationState); } else { startTask = new FuncTask <GitInstallationState>(cancellationToken, () => { return(VerifyPortableGitInstallation()); }) { Name = "Git Installation - Verify" }; } startTask = startTask.Then(new FuncTask <GitInstallationState, GitInstallationState>(cancellationToken, (success, installState) => { if (installState.GitIsValid && installState.GitLfsIsValid) { return(installState); } installState = VerifyZipFiles(installState); installState = GrabZipFromResourcesIfNeeded(installState); return(installState); }) { Name = "Git Installation - Validate" } ); startTask.OnEnd += (thisTask, installState, success, exception) => { if (installState.GitIsValid && installState.GitLfsIsValid) { Logger.Trace("Skipping git installation"); thisTask.Then(installationTask); return; } var downloadZipTask = DownloadZipsIfNeeded(installState); downloadZipTask.OnEnd += ExtractPortableGit; thisTask.Then(downloadZipTask); }; return(startTask); }