예제 #1
0
            public GitInstallDetails(NPath baseDataPath, bool onWindows)
            {
                this.onWindows = onWindows;

                ZipPath = baseDataPath.Combine("downloads");
                ZipPath.EnsureDirectoryExists();
                GitZipPath    = ZipPath.Combine(gitZip);
                GitLfsZipPath = ZipPath.Combine(gitLfsZip);

                GitInstallationPath = baseDataPath.Combine(GitDirectory);
                GitExecutablePath   = GitInstallationPath.Combine(onWindows ? "cmd" : "bin", "git" + DefaultEnvironment.ExecutableExt);

                GitLfsInstallationPath = baseDataPath.Combine(GitLfsDirectory);
                GitLfsExecutablePath   = GitLfsInstallationPath.Combine("git-lfs" + DefaultEnvironment.ExecutableExt);

                if (onWindows)
                {
                    GitPackageFeed    = packageFeed + $"windows/{GitPackageName}";
                    GitLfsPackageFeed = packageFeed + $"windows/{GitLfsPackageName}";
                }
                else
                {
                    GitPackageFeed    = packageFeed + $"mac/{GitPackageName}";
                    GitLfsPackageFeed = packageFeed + $"mac/{GitLfsPackageName}";
                }
            }
예제 #2
0
            public GitInstallDetails(SPath baseDataPath, IEnvironment environment)
            {
                ZipPath = baseDataPath.Combine("downloads");
                ZipPath.EnsureDirectoryExists();

                GitInstallationPath = baseDataPath.Combine(GitDirectory);
                GitExecutablePath   = GitInstallationPath.Combine(environment.IsWindows ? "cmd" : "bin", "git" + UnityEnvironment.ExecutableExtension);
                //GitLfsExecutablePath = GitExecutablePath.Parent.Combine("git-lfs" + UnityEnvironment.ExecutableExtension);
                GitLfsExecutablePath = SPath.Default;
                GitPackageFeed       = packageFeed;
            }
예제 #3
0
            public GitInstallDetails(NPath baseDataPath, IEnvironment environment)
            {
                ZipPath = baseDataPath.Combine("downloads");
                ZipPath.EnsureDirectoryExists();

                GitInstallationPath = baseDataPath.Combine(GitDirectory);
                GitExecutablePath   = GitInstallationPath.Combine(environment.IsWindows ? "cmd" : "bin", "git" + DefaultEnvironment.ExecutableExt);

                GitLfsInstallationPath = GitLfsExecutablePath = GitInstallationPath;
                if (environment.IsWindows)
                {
                    GitLfsExecutablePath = GitLfsInstallationPath.Combine(environment.Is32Bit ? "mingw32" : "mingw64");
                }
                GitLfsExecutablePath = GitLfsExecutablePath.Combine("libexec", "git-core");
                GitLfsExecutablePath = GitLfsExecutablePath.Combine("git-lfs" + DefaultEnvironment.ExecutableExt);
                GitManifest          = baseDataPath.Combine(GitPackageName);
            }
예제 #4
0
        public Task <bool> SetupGitIfNeeded(NPath tempPath, IProgress <float> zipFileProgress = null,
                                            IProgress <long> estimatedDurationProgress        = null)
        {
            logger.Trace("SetupGitIfNeeded");

            cancellationToken.ThrowIfCancellationRequested();

            if (IsPortableGitExtracted())
            {
                logger.Trace("Already extracted {0}, returning", GitInstallationPath);
                return(TaskEx.FromResult(true));
            }

            cancellationToken.ThrowIfCancellationRequested();

            var archiveFilePath = AssemblyResources.ToFile(ResourceType.Platform, GitZipFile, tempPath, environment);

            if (!archiveFilePath.FileExists())
            {
                logger.Warning("Archive \"{0}\" missing", archiveFilePath.ToString());

                archiveFilePath = environment.ExtensionInstallPath.Combine(archiveFilePath);
                if (!archiveFilePath.FileExists())
                {
                    logger.Warning("Archive \"{0}\" missing, returning", archiveFilePath.ToString());
                    return(TaskEx.FromResult(false));
                }
            }

            cancellationToken.ThrowIfCancellationRequested();

            var unzipPath = tempPath.Combine("git");

            try
            {
                logger.Trace("Extracting \"{0}\" to \"{1}\"", archiveFilePath, unzipPath);

                extractCallback(archiveFilePath, unzipPath, cancellationToken, zipFileProgress,
                                estimatedDurationProgress);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error ExtractingArchive Source:\"{0}\" OutDir:\"{1}\"", archiveFilePath, tempPath);
                return(TaskEx.FromResult(false));
            }

            cancellationToken.ThrowIfCancellationRequested();

            try
            {
                GitInstallationPath.DeleteIfExists();
                GitInstallationPath.EnsureParentDirectoryExists();

                logger.Trace("Moving \"{0}\" to \"{1}\"", unzipPath, GitInstallationPath);

                unzipPath.Move(GitInstallationPath);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error Moving \"{0}\" to \"{1}\"", tempPath, GitInstallationPath);
                return(TaskEx.FromResult(false));
            }
            unzipPath.DeleteIfExists();
            return(TaskEx.FromResult(true));
        }