public void Configure(ProcessStartInfo psi, NPath workingDirectory, bool dontSetupGit = false) { psi.WorkingDirectory = workingDirectory; psi.EnvironmentVariables["HOME"] = NPath.HomeDirectory; psi.EnvironmentVariables["TMP"] = psi.EnvironmentVariables["TEMP"] = NPath.SystemTemp; var path = Environment.Path; psi.EnvironmentVariables["GHU_WORKINGDIR"] = workingDirectory; var pathEnvVarKey = Environment.GetEnvironmentVariableKey("PATH"); if (dontSetupGit) { psi.EnvironmentVariables["GHU_FULLPATH"] = path; psi.EnvironmentVariables[pathEnvVarKey] = path; return; } Guard.ArgumentNotNull(psi, "psi"); var pathEntries = new List <string>(); string separator = Environment.IsWindows ? ";" : ":"; NPath libexecPath = NPath.Default; List <string> gitPathEntries = new List <string>(); if (Environment.GitInstallPath.IsInitialized) { var gitPathRoot = Environment.GitExecutablePath.Resolve().Parent.Parent; var gitExecutableDir = Environment.GitExecutablePath.Parent; // original path to git (might be different from install path if it's a symlink) var baseExecPath = gitPathRoot; var binPath = baseExecPath; if (Environment.IsWindows) { if (baseExecPath.DirectoryExists("mingw32")) { baseExecPath = baseExecPath.Combine("mingw32"); } else { baseExecPath = baseExecPath.Combine("mingw64"); } binPath = baseExecPath.Combine("bin"); } libexecPath = baseExecPath.Combine("libexec", "git-core"); if (!libexecPath.DirectoryExists()) { libexecPath = NPath.Default; } if (Environment.IsWindows) { gitPathEntries.AddRange(new[] { gitPathRoot.Combine("cmd").ToString(), gitPathRoot.Combine("usr", "bin") }); } else { gitPathEntries.Add(gitExecutableDir.ToString()); } if (libexecPath.IsInitialized) { gitPathEntries.Add(libexecPath); } gitPathEntries.Add(binPath); // we can only set this env var if there is a libexec/git-core. git will bypass internally bundled tools if this env var // is set, which will break Apple's system git on certain tools (like osx-credentialmanager) if (libexecPath.IsInitialized) { psi.EnvironmentVariables["GIT_EXEC_PATH"] = libexecPath.ToString(); } } if (Environment.GitLfsInstallPath.IsInitialized && libexecPath != Environment.GitLfsInstallPath) { pathEntries.Add(Environment.GitLfsInstallPath); } if (gitPathEntries.Count > 0) { pathEntries.AddRange(gitPathEntries); } pathEntries.Add("END"); path = string.Join(separator, pathEntries.ToArray()) + separator + path; psi.EnvironmentVariables["GHU_FULLPATH"] = path; psi.EnvironmentVariables[pathEnvVarKey] = path; //TODO: Remove with Git LFS Locking becomes standard psi.EnvironmentVariables["GITLFSLOCKSENABLED"] = "1"; if (Environment.IsWindows) { psi.EnvironmentVariables["PLINK_PROTOCOL"] = "ssh"; psi.EnvironmentVariables["TERM"] = "msys"; } var httpProxy = Environment.GetEnvironmentVariable("HTTP_PROXY"); if (!string.IsNullOrEmpty(httpProxy)) { psi.EnvironmentVariables["HTTP_PROXY"] = httpProxy; } var httpsProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY"); if (!string.IsNullOrEmpty(httpsProxy)) { psi.EnvironmentVariables["HTTPS_PROXY"] = httpsProxy; } psi.EnvironmentVariables["DISPLAY"] = "0"; }
public ITask RequestLock(NPath file) => repositoryManager.LockFile(file);
public ITask ReleaseLock(NPath file, bool force) => repositoryManager.UnlockFile(file, force);
public GitInstaller(IEnvironment environment, IZipHelper sharpZipLibHelper, CancellationToken cancellationToken, GitInstallDetails installDetails, NPath gitArchiveFilePath, NPath gitLfsArchivePath) { this.environment = environment; this.sharpZipLibHelper = sharpZipLibHelper; this.cancellationToken = cancellationToken; this.installDetails = installDetails; this.gitArchiveFilePath = gitArchiveFilePath; this.gitLfsArchivePath = gitLfsArchivePath; }
public NPath GetGitLfsExecutablePath(NPath gitInstallRoot) { return(onWindows ? gitInstallRoot.Combine("mingw32", "libexec", "git-core", GitLfsExecutable) : gitInstallRoot.Combine("libexec", "git-core", GitLfsExecutable)); }
public SimpleProcessTask(CancellationToken token, NPath fullPathToExecutable, string arguments) : base(token, new SimpleOutputProcessor()) { this.fullPathToExecutable = fullPathToExecutable; this.arguments = arguments; }
public GitInstaller(IEnvironment environment, CancellationToken cancellationToken, GitInstallDetails installDetails, NPath gitArchiveFilePath, NPath gitLfsArchivePath) : this( environment, ZipHelper.Instance, cancellationToken, installDetails, gitArchiveFilePath, gitLfsArchivePath) { }
public static T Configure <T>(this T task, IProcessManager processManager, string executable, string arguments, NPath workingDirectory = null, bool withInput = false) where T : IProcess { return(processManager.Configure(task, executable, arguments, workingDirectory, withInput)); }
public static RepositoryManager CreateInstance(IPlatform platform, ITaskManager taskManager, IGitClient gitClient, IProcessManager processManager, IFileSystem fileSystem, NPath repositoryRoot) { var repositoryPathConfiguration = new RepositoryPathConfiguration(repositoryRoot); string filePath = repositoryPathConfiguration.DotGitConfig; var gitConfig = new GitConfig(filePath); var repositoryWatcher = new RepositoryWatcher(platform, repositoryPathConfiguration, taskManager.Token); return(new RepositoryManager(gitConfig, repositoryWatcher, gitClient, processManager, fileSystem, taskManager.Token, repositoryPathConfiguration)); }
public void Initialize(string unityVersion, NPath extensionInstallPath, NPath unityApplicationPath, NPath unityApplicationContentsPath, NPath assetsPath) { ExtensionInstallPath = extensionInstallPath; UnityApplication = unityApplicationPath; UnityApplicationContents = unityApplicationContentsPath; UnityAssetsPath = assetsPath; UnityProjectPath = assetsPath.Parent; UnityVersion = unityVersion; User = new User(CacheContainer); }
public bool ValidateGitInstall(NPath path) { return(path.FileExists()); }
public void Run() { isBusy = true; progress.UpdateProgress(0, 100, "Initializing..."); if (firstRun) { UsageTracker.IncrementNumberOfStartups(); } var thread = new Thread(() => { GitInstallationState state = new GitInstallationState(); try { if (Environment.IsMac) { var getEnvPath = new SimpleProcessTask(TaskManager.Token, "bash".ToNPath(), "-c \"/usr/libexec/path_helper\"") .Configure(ProcessManager, dontSetupGit: true) .Catch(e => true); // make sure this doesn't throw if the task fails var path = getEnvPath.RunSynchronously(); if (getEnvPath.Successful) { Logger.Trace("Existing Environment Path Original:{0} Updated:{1}", Environment.Path, path); Environment.Path = path?.Split(new[] { "\"" }, StringSplitOptions.None)[1]; } } progress.UpdateProgress(20, 100, "Setting up octorun..."); Environment.OctorunScriptPath = new OctorunInstaller(Environment, TaskManager) .SetupOctorunIfNeeded(); progress.UpdateProgress(50, 100, "Setting up git..."); state = Environment.GitInstallationState; if (!state.GitIsValid && !state.GitLfsIsValid && FirstRun) { // importing old settings NPath gitExecutablePath = Environment.SystemSettings.Get(Constants.GitInstallPathKey, NPath.Default); if (gitExecutablePath.IsInitialized) { Environment.SystemSettings.Unset(Constants.GitInstallPathKey); state.GitExecutablePath = gitExecutablePath; state.GitInstallationPath = gitExecutablePath.Parent.Parent; Environment.GitInstallationState = state; } } var installer = new GitInstaller(Environment, ProcessManager, TaskManager.Token); installer.Progress.OnProgress += progressReporter.UpdateProgress; if (state.GitIsValid && state.GitLfsIsValid) { if (firstRun) { installer.ValidateGitVersion(state); if (state.GitIsValid) { installer.ValidateGitLfsVersion(state); } } } if (!state.GitIsValid || !state.GitLfsIsValid) { state = installer.SetupGitIfNeeded(); } SetupGit(state); progress.UpdateProgress(80, 100, "Initializing repository..."); if (state.GitIsValid && state.GitLfsIsValid) { RestartRepository(); } progress.UpdateProgress(100, 100, "Initialized"); } catch (Exception ex) { Logger.Error(ex, "A problem ocurred setting up Git"); progress.UpdateProgress(90, 100, "Initialization failed"); } new ActionTask <bool>(TaskManager.Token, (s, gitIsValid) => { InitializationComplete(); if (gitIsValid) { InitializeUI(); } }, () => state.GitIsValid && state.GitLfsIsValid) { Affinity = TaskAffinity.UI } .Start(); }); thread.Start(); }