示例#1
0
        public GitInstallationState VerifyGitSettings(GitInstallationState state = null)
        {
            UpdateTask("Verifying git settings", 100);

            try
            {
                state = state ?? new GitInstallationState(environment);
                if (!state.GitExecutablePath.IsInitialized)
                {
                    return(state);
                }

                state = ValidateGitVersion(state);
                if (state.GitIsValid)
                {
                    state.GitInstallationPath = state.GitExecutablePath.Parent.Parent;
                }

                state = ValidateGitLfsVersion(state);

                if (state.GitLfsIsValid && state.GitInstallationPath != installDetails.GitInstallationPath)
                {
                    state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
                }

                return(state);
            }
            finally
            {
                UpdateTask("Verifying git settings", 100);
            }
        }
示例#2
0
        private GitInstallationState GetZipsIfNeeded(GitInstallationState state)
        {
            if (state.GitZipExists || state.GitPackage == null)
            {
                return(state);
            }

            var asset      = state.GitPackage.DugitePackage;
            var downloader = new Downloader(environment.FileSystem);

            downloader.QueueDownload(asset.Url, installDetails.ZipPath, asset.Name);

            downloader
            .Progress(progressReporter.UpdateProgress)
            .Catch(e =>
            {
                LogHelper.Trace(e, "Failed to download");
                return(true);
            });

            downloader.RunSynchronously();

            state.GitZipExists = state.GitZipPath.IsInitialized && state.GitZipPath.FileExists();

            return(state);
        }
示例#3
0
        private GitInstallationState VerifyZipFiles(GitInstallationState state)
        {
            UpdateTask("Verifying package files", 100);
            try
            {
                if (state.GitIsValid || state.GitPackage == null)
                {
                    return(state);
                }

                var asset = state.GitPackage.DugitePackage;
                state.GitZipPath   = installDetails.ZipPath.Combine(asset.Name);
                state.GitZipExists = state.GitZipPath.FileExists();
                if (!Utils.VerifyFileIntegrity(state.GitZipPath, asset.Hash))
                {
                    state.GitZipPath.DeleteIfExists();
                }
                state.GitZipExists = state.GitZipPath.FileExists();
                return(state);
            }
            finally
            {
                UpdateTask("Verifying package files", 100);
            }
        }
示例#4
0
        private GitInstallationState ExtractGit(GitInstallationState state)
        {
            var tempZipExtractPath = NPath.CreateTempDirectory("ghu_extract_git");

            if (state.GitZipExists && !state.GitIsValid)
            {
                var gitExtractPath = tempZipExtractPath.Combine("git").CreateDirectory();
                var unzipTask      = new UnzipTask(cancellationToken, state.GitZipPath,
                                                   gitExtractPath, sharpZipLibHelper,
                                                   environment.FileSystem)
                                     .Progress(progressReporter.UpdateProgress)
                                     .Catch(e =>
                {
                    LogHelper.Trace(e, "Failed to unzip " + state.GitZipPath);
                    return(true);
                });

                unzipTask.RunSynchronously();
                var target = state.GitInstallationPath;
                if (unzipTask.Successful)
                {
                    Logger.Trace("Moving Git source:{0} target:{1}", gitExtractPath.ToString(), target.ToString());

                    CopyHelper.Copy(gitExtractPath, target);

                    state.GitIsValid = true;

                    state.IsCustomGitPath = state.GitExecutablePath != installDetails.GitExecutablePath;
                }
            }

            tempZipExtractPath.DeleteIfExists();
            return(state);
        }
示例#5
0
        public GitInstallationState GetZipsIfNeeded(GitInstallationState state)
        {
            if (state.GitZipExists)
            {
                return(state);
            }

            var downloader = new Downloader(environment.FileSystem);

            downloader.Catch(e => {
                LogHelper.Trace(e, "Failed to download");
                return(true);
            });
            downloader.Progress(progressReporter.UpdateProgress);

            var asset = state.GitReleaseManifest.DugitePackage;

            if (!state.GitZipExists && !state.GitIsValid && state.GitReleaseManifest != null)
            {
                downloader.QueueDownload(asset.Url, installDetails.ZipPath, asset.Name);
            }
            downloader.RunSynchronously();

            state.GitZipExists = installDetails.GitZipPath.FileExists();
            return(state);
        }
示例#6
0
        private GitInstallationState GetZipsIfNeeded(GitInstallationState state)
        {
            if (state.GitZipExists && state.GitLfsZipExists)
            {
                return(state);
            }

            var downloader = new Downloader(environment.FileSystem);

            downloader.Catch(e =>
            {
                LogHelper.Trace(e, "Failed to download");
                return(true);
            });
            downloader.Progress(p => Progress.UpdateProgress(20 + (long)(20 * p.Percentage), 100, downloader.Message));
            if (!state.GitZipExists && !state.GitIsValid && state.GitPackage != null)
            {
                downloader.QueueDownload(state.GitPackage.Uri, installDetails.ZipPath);
            }
            if (!state.GitLfsZipExists && !state.GitLfsIsValid && state.GitLfsPackage != null)
            {
                downloader.QueueDownload(state.GitLfsPackage.Uri, installDetails.ZipPath);
            }
            downloader.RunSynchronously();

            state.GitZipExists    = installDetails.GitZipPath.FileExists();
            state.GitLfsZipExists = installDetails.GitLfsZipPath.FileExists();
            Progress.UpdateProgress(30, 100);

            return(state);
        }
示例#7
0
        private GitInstallationState CheckForGitUpdates(GitInstallationState state)
        {
            if (state.IsCustomGitPath)
            {
                return(state);
            }

            if (state.GitInstallationPath != installDetails.GitInstallationPath)
            {
                return(state);
            }

            state.GitPackage = DugiteReleaseManifest.Load(installDetails.GitManifest, GitInstallDetails.GitPackageFeed, environment);
            if (state.GitPackage == null)
            {
                return(state);
            }

            state.GitIsValid = state.GitVersion >= state.GitPackage.Version;
            if (!state.GitIsValid)
            {
                Logger.Trace($"{installDetails.GitExecutablePath} is out of date");
            }

            return(state);
        }
示例#8
0
        public GitInstallationState VerifyGitSettings(GitInstallationState state = null)
        {
            state = state ?? environment.GitInstallationState;
            if (!state.GitExecutablePath.IsInitialized && !state.GitLfsExecutablePath.IsInitialized)
            {
                return(state);
            }

            state = ValidateGitVersion(state);
            if (state.GitIsValid)
            {
                state.GitInstallationPath = state.GitExecutablePath.Parent.Parent;
            }

            if (!state.GitLfsExecutablePath.IsInitialized)
            {
                // look for it in the directory where we would install it from the bundle
                state.GitLfsExecutablePath = installDetails.GitLfsExecutablePath;
            }

            state = ValidateGitLfsVersion(state);

            if (state.GitLfsIsValid)
            {
                state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
            }

            return(state);
        }
示例#9
0
        private GitInstallationState CheckForGitUpdates(GitInstallationState state)
        {
            if (state.GitInstallationPath == installDetails.GitInstallationPath)
            {
                state.GitPackage = Package.Load(environment, installDetails.GitPackageFeed);
                if (state.GitPackage != null)
                {
                    state.GitIsValid = state.GitVersion >= state.GitPackage.Version;
                    if (state.GitIsValid)
                    {
                        state.IsCustomGitPath = state.GitExecutablePath != installDetails.GitExecutablePath;
                    }
                    else
                    {
                        Logger.Trace($"{installDetails.GitExecutablePath} is out of date");
                    }
                }
            }

            if (state.GitLfsInstallationPath == installDetails.GitLfsInstallationPath)
            {
                state.GitLfsPackage = Package.Load(environment, installDetails.GitLfsPackageFeed);
                if (state.GitLfsPackage != null)
                {
                    state.GitLfsIsValid = state.GitLfsVersion >= state.GitLfsPackage.Version;
                    if (!state.GitLfsIsValid)
                    {
                        Logger.Trace($"{installDetails.GitLfsExecutablePath} is out of date");
                    }
                }
            }
            return(state);
        }
示例#10
0
        public GitInstallationState ValidateGitLfsVersion(GitInstallationState state)
        {
            // default installation doesn't have a standalone "git-lfs" exe
            if (state.GitInstallationPath == installDetails.GitInstallationPath)
            {
                state.GitLfsIsValid = true;
                state.GitLfsVersion = state.GitVersion;
                return(state);
            }

            if (!state.GitLfsExecutablePath.IsInitialized || !state.GitLfsExecutablePath.FileExists())
            {
                state.GitLfsIsValid = false;
                return(state);
            }

            var version = new ProcessTask <TheVersion>(Token, state.GitLfsExecutablePath, "version", new LfsVersionOutputProcessor())
                          .Configure(processManager)
                          .Progress(progressReporter.UpdateProgress)
                          .Catch(e => true)
                          .RunSynchronously();

            state.GitLfsIsValid = version >= Constants.MinimumGitLfsVersion;
            state.GitLfsVersion = version;
            return(state);
        }
示例#11
0
        private GitInstallationState SetupGitIfNeeded()
        {
            UpdateTask("Setting up git...", 100);

            bool skipSystemProbing = currentState != null;

            try
            {
                currentState = VerifyGitSettings(currentState);
                if (currentState.GitIsValid && currentState.GitLfsIsValid)
                {
                    Logger.Trace("Using git install path from settings: {0}", currentState.GitExecutablePath);
                    currentState.GitLastCheckTime = DateTimeOffset.Now;
                    return(currentState);
                }

                //if (!skipSystemProbing)
                //{
                //    if (environment.IsMac)
                //        currentState = FindGit(currentState);
                //}

                currentState = SetDefaultPaths(currentState);
                currentState = CheckForGitUpdates(currentState);

                if (currentState.GitIsValid && currentState.GitLfsIsValid)
                {
                    currentState.GitLastCheckTime = DateTimeOffset.Now;
                    return(currentState);
                }

                currentState = VerifyZipFiles(currentState);
                currentState = GetZipsIfNeeded(currentState);
                currentState = ExtractGit(currentState);

                if (!skipSystemProbing)
                {
                    // if installing from zip failed (internet down maybe?), try to find a usable system git
                    if (!currentState.GitIsValid &&
                        currentState.GitInstallationPath == installDetails.GitInstallationPath)
                    {
                        currentState = FindGit(currentState);
                    }
                    if (!currentState.GitLfsIsValid &&
                        currentState.GitLfsInstallationPath == installDetails.GitLfsInstallationPath)
                    {
                        currentState = FindGitLfs(currentState);
                    }
                }

                currentState.GitLastCheckTime = DateTimeOffset.Now;
                return(currentState);
            }
            finally
            {
                UpdateTask("Setting up git...", 100);
            }
        }
示例#12
0
        private GitInstallationState ExtractGit(GitInstallationState state)
        {
            var tempZipExtractPath = NPath.CreateTempDirectory("git_zip_extract_zip_paths");

            if (state.GitZipExists && !state.GitIsValid)
            {
                var gitExtractPath = tempZipExtractPath.Combine("git").CreateDirectory();
                var unzipTask      = new UnzipTask(cancellationToken, installDetails.GitZipPath,
                                                   gitExtractPath, sharpZipLibHelper,
                                                   environment.FileSystem)
                                     .Catch(e =>
                {
                    LogHelper.Trace(e, "Failed to unzip " + installDetails.GitZipPath);
                    return(true);
                });
                unzipTask.Progress(p => Progress.UpdateProgress(40 + (long)(20 * p.Percentage), 100, unzipTask.Message));
                var source = unzipTask.RunSynchronously();
                var target = state.GitInstallationPath;
                if (unzipTask.Successful)
                {
                    Logger.Trace("Moving Git source:{0} target:{1}", source.ToString(), target.ToString());

                    CopyHelper.Copy(source, target);

                    state.GitIsValid = true;

                    state.IsCustomGitPath = state.GitExecutablePath != installDetails.GitExecutablePath;
                }
            }

            if (state.GitLfsZipExists && !state.GitLfsIsValid)
            {
                var gitLfsExtractPath = tempZipExtractPath.Combine("git-lfs").CreateDirectory();
                var unzipTask         = new UnzipTask(cancellationToken, installDetails.GitLfsZipPath,
                                                      gitLfsExtractPath, sharpZipLibHelper,
                                                      environment.FileSystem)
                                        .Catch(e =>
                {
                    LogHelper.Trace(e, "Failed to unzip " + installDetails.GitLfsZipPath);
                    return(true);
                });
                unzipTask.Progress(p => Progress.UpdateProgress(60 + (long)(20 * p.Percentage), 100, unzipTask.Message));
                var source = unzipTask.RunSynchronously();
                var target = state.GitLfsInstallationPath;
                if (unzipTask.Successful)
                {
                    Logger.Trace("Moving GitLFS source:{0} target:{1}", source.ToString(), target.ToString());

                    CopyHelper.Copy(source, target);

                    state.GitLfsIsValid = true;
                }
            }

            tempZipExtractPath.DeleteIfExists();
            return(state);
        }
示例#13
0
 public GitInstallationState SetDefaultPaths(GitInstallationState state)
 {
     if (!state.GitIsValid)
     {
         state = installDetails.GetDefaults();
         state = ValidateGitVersion(state);
     }
     return(state);
 }
示例#14
0
        private FuncTask <NPath> ExtractPortableGit(GitInstallationState state)
        {
            ITask <NPath> task = null;
            var           tempZipExtractPath = NPath.CreateTempDirectory("git_zip_extract_zip_paths");
            var           gitExtractPath     = tempZipExtractPath.Combine("git").CreateDirectory();

            if (!state.GitIsValid)
            {
                ITask <NPath> unzipTask = new UnzipTask(cancellationToken, installDetails.GitZipPath, gitExtractPath, sharpZipLibHelper,
                                                        environment.FileSystem);
                unzipTask.Progress(p => installationTask.UpdateProgress(40 + (long)(20 * p.Percentage), 100, unzipTask.Name));

                unzipTask = unzipTask.Then((s, path) =>
                {
                    var source = path;
                    var target = installDetails.GitInstallationPath;
                    target.DeleteIfExists();
                    target.EnsureParentDirectoryExists();
                    Logger.Trace($"Moving '{source}' to '{target}'");
                    source.Move(target);
                    state.GitExists  = installDetails.GitExecutablePath.FileExists();
                    state.GitIsValid = s;
                    return(path);
                });
                task = unzipTask;
            }

            var gitLfsExtractPath = tempZipExtractPath.Combine("git-lfs").CreateDirectory();

            if (!state.GitLfsIsValid)
            {
                ITask <NPath> unzipTask = new UnzipTask(cancellationToken, installDetails.GitLfsZipPath, gitLfsExtractPath, sharpZipLibHelper,
                                                        environment.FileSystem);
                unzipTask.Progress(p => installationTask.UpdateProgress(60 + (long)(20 * p.Percentage), 100, unzipTask.Name));

                unzipTask = unzipTask.Then((s, path) =>
                {
                    var source = path.Combine(installDetails.GitLfsExecutable);
                    var target = installDetails.GetGitLfsExecutablePath(installDetails.GitInstallationPath);
                    target.DeleteIfExists();
                    target.EnsureParentDirectoryExists();
                    Logger.Trace($"Moving '{source}' to '{target}'");
                    source.Move(target);
                    state.GitExists  = target.FileExists();
                    state.GitIsValid = s;
                    return(path);
                });
                task = task?.Then(unzipTask) ?? unzipTask;
            }

            return(task.Finally(new FuncTask <NPath>(cancellationToken, (success) =>
            {
                tempZipExtractPath.DeleteIfExists();
                return installDetails.GitInstallationPath;
            })));
        }
示例#15
0
        private GitInstallationState GrabZipFromResourcesIfNeeded(GitInstallationState state)
        {
            if (!state.GitZipExists && !state.GitIsValid && state.GitInstallationPath == installDetails.GitInstallationPath)
            {
                AssemblyResources.ToFile(ResourceType.Platform, "git.zip", installDetails.ZipPath, environment);
            }
            state.GitZipExists = installDetails.GitZipPath.FileExists();

            return(state);
        }
示例#16
0
        public GitInstallationState SetupGitIfNeeded(GitInstallationState state = null)
        {
            var skipSystemProbing = state != null;

            state = VerifyGitSettings(state);
            if (state.GitIsValid && state.GitLfsIsValid)
            {
                Logger.Trace("Using git install path from settings: {0}", state.GitExecutablePath);
                state.GitLastCheckTime = DateTimeOffset.Now;
                return(state);
            }

            if (!skipSystemProbing)
            {
                if (environment.IsMac)
                {
                    state = FindGit(state);
                }
            }

            state = SetDefaultPaths(state);
            state = CheckForGitUpdates(state);

            if (state.GitIsValid && state.GitLfsIsValid)
            {
                state.GitLastCheckTime = DateTimeOffset.Now;
                return(state);
            }

            state = VerifyZipFiles(state);
            // on developer builds, prefer local zips over downloading
#if DEVELOPER_BUILD
            state = GrabZipFromResourcesIfNeeded(state);
            state = GetZipsIfNeeded(state);
#else
            state = GetZipsIfNeeded(state);
            state = GrabZipFromResourcesIfNeeded(state);
#endif
            state = ExtractGit(state);

            // if installing from zip failed (internet down maybe?), try to find a usable system git
            if (!state.GitIsValid && state.GitInstallationPath == installDetails.GitInstallationPath)
            {
                state = FindGit(state);
            }
            if (!state.GitLfsIsValid && state.GitLfsInstallationPath == installDetails.GitLfsInstallationPath)
            {
                state = FindGitLfs(state);
            }
            state.GitLastCheckTime = DateTimeOffset.Now;
            return(state);
        }
示例#17
0
 public GitInstaller(IGitEnvironment environment, IProcessManager processManager,
                     CancellationToken token,
                     GitInstallationState state       = null,
                     GitInstallDetails installDetails = null)
     : base(token)
 {
     this.environment             = environment;
     this.processManager          = processManager;
     this.state                   = state;
     this.sharpZipLibHelper       = ZipHelper.Instance;
     this.installDetails          = installDetails ?? new GitInstallDetails(environment.UserCachePath, environment);
     progressReporter.OnProgress += progress.UpdateProgress;
 }
示例#18
0
 public GitInstaller(IPlatform platform,
                     GitInstallationState state       = null,
                     GitInstallDetails installDetails = null,
                     CancellationToken token          = default)
     : base(platform.TaskManager, token)
 {
     this.platform                = platform;
     this.currentState            = state;
     this.sharpZipLibHelper       = ZipHelper.Instance;
     this.cancellationToken       = token;
     this.installDetails          = installDetails ?? new GitInstallDetails(platform.Environment.UserCachePath, platform.Environment);
     progressReporter.OnProgress += progress.UpdateProgress;
 }
示例#19
0
        private ITask <NPath> CreateDownloadTask(GitInstallationState state)
        {
            var downloader = new Downloader();

            downloader.QueueDownload(installDetails.GitZipUrl, installDetails.GitZipMd5Url, installDetails.ZipPath);
            downloader.QueueDownload(installDetails.GitLfsZipUrl, installDetails.GitLfsZipMd5Url, installDetails.ZipPath);
            return(downloader.Then((_, data) =>
            {
                state.GitZipExists = installDetails.GitZipPath.FileExists();
                state.GitLfsZipExists = installDetails.GitLfsZipPath.FileExists();
                installationTask.UpdateProgress(40, 100);
                return installDetails.ZipPath;
            }));
        }
示例#20
0
        private GitInstallationState VerifyGitInstallation()
        {
            var state = new GitInstallationState();

            state.GitExists       = installDetails.GitExecutablePath.IsInitialized && installDetails.GitExecutablePath.FileExists();
            state.GitLfsExists    = installDetails.GitLfsExecutablePath.IsInitialized && installDetails.GitLfsExecutablePath.FileExists();
            state.GitZipExists    = installDetails.GitZipPath.FileExists();
            state.GitLfsZipExists = installDetails.GitLfsZipPath.FileExists();

            if (state.GitExists)
            {
                var actualmd5   = installDetails.GitExecutablePath.CalculateMD5();
                var expectedmd5 = environment.IsWindows ? GitInstallDetails.WindowsGitExecutableMD5 : GitInstallDetails.MacGitExecutableMD5;
                state.GitIsValid = expectedmd5.Equals(actualmd5, StringComparison.InvariantCultureIgnoreCase);
                if (!state.GitIsValid)
                {
                    Logger.Trace($"Path {installDetails.GitExecutablePath} has MD5 {actualmd5} expected {expectedmd5}");
                }
            }
            else
            {
                Logger.Trace($"{installDetails.GitExecutablePath} does not exist");
            }

            if (state.GitLfsExists)
            {
                var actualmd5   = installDetails.GitLfsExecutablePath.CalculateMD5();
                var expectedmd5 = environment.IsWindows ? GitInstallDetails.WindowsGitLfsExecutableMD5 : GitInstallDetails.MacGitLfsExecutableMD5;
                state.GitLfsIsValid = expectedmd5.Equals(actualmd5, StringComparison.InvariantCultureIgnoreCase);
                if (!state.GitLfsIsValid)
                {
                    Logger.Trace($"Path {installDetails.GitLfsExecutablePath} has MD5 {actualmd5} expected {expectedmd5}");
                }
            }
            else
            {
                Logger.Trace($"{installDetails.GitLfsExecutablePath} does not exist");
            }

            if (!state.GitZipExists)
            {
                Logger.Trace($"{installDetails.GitZipPath} does not exist");
            }
            if (!state.GitLfsZipExists)
            {
                Logger.Trace($"{installDetails.GitLfsZipPath} does not exist");
            }
            installationTask.UpdateProgress(10, 100);
            return(state);
        }
示例#21
0
        private GitInstallationState GrabZipFromResourcesIfNeeded(GitInstallationState state)
        {
            if (!state.GitZipExists)
            {
                AssemblyResources.ToFile(ResourceType.Platform, "git.zip", installDetails.ZipPath, environment);
            }
            state.GitZipExists = installDetails.GitZipPath.FileExists();

            if (!state.GitLfsZipExists)
            {
                AssemblyResources.ToFile(ResourceType.Platform, "git-lfs.zip", installDetails.ZipPath, environment);
            }
            state.GitLfsZipExists = installDetails.GitLfsZipPath.FileExists();
            installationTask.UpdateProgress(30, 100);
            return(state);
        }
示例#22
0
        public GitInstallationState ValidateGitVersion(GitInstallationState state)
        {
            if (!state.GitExecutablePath.IsInitialized || !state.GitExecutablePath.FileExists())
            {
                state.GitIsValid = false;
                return(state);
            }
            var version = new GitVersionTask(cancellationToken)
                          .Configure(processManager, state.GitExecutablePath, dontSetupGit: true)
                          .Catch(e => true)
                          .RunWithReturn(true);

            state.GitIsValid = version >= Constants.MinimumGitVersion;
            state.GitVersion = version;
            return(state);
        }
示例#23
0
        public GitInstallationState ValidateGitLfsVersion(GitInstallationState state)
        {
            if (!state.GitLfsExecutablePath.IsInitialized || !state.GitLfsExecutablePath.FileExists())
            {
                state.GitLfsIsValid = false;
                return(state);
            }
            var version = new ProcessTask <TheVersion>(cancellationToken, "version", new LfsVersionOutputProcessor())
                          .Configure(processManager, state.GitLfsExecutablePath, dontSetupGit: true)
                          .Catch(e => true)
                          .RunSynchronously();

            state.GitLfsIsValid = version >= Constants.MinimumGitLfsVersion;
            state.GitLfsVersion = version;
            return(state);
        }
示例#24
0
 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);
 }
示例#25
0
        public GitInstallationState ValidateGitLfsVersion(GitInstallationState state)
        {
            if (!state.GitLfsExecutablePath.IsInitialized || !state.GitLfsExecutablePath.FileExists())
            {
                state.GitLfsIsValid = false;
                return(state);
            }
            var version = new GitLfsVersionTask(TaskManager, platform.DefaultProcessEnvironment, state.GitLfsExecutablePath)
                          .Configure(platform.ProcessManager)
                          .Progress(progressReporter.UpdateProgress)
                          .Catch(e => true)
                          .RunSynchronously();

            state.GitLfsIsValid = version >= Constants.MinimumGitLfsVersion;
            state.GitLfsVersion = version;
            return(state);
        }
示例#26
0
 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);
 }
示例#27
0
        public GitInstallationState SetDefaultPaths(GitInstallationState state)
        {
            if (!state.GitIsValid && environment.IsWindows)
            {
                state.GitInstallationPath = installDetails.GitInstallationPath;
                state.GitExecutablePath   = installDetails.GitExecutablePath;
                state = ValidateGitVersion(state);
            }

            if (!state.GitLfsIsValid)
            {
                state.GitLfsExecutablePath   = installDetails.GitLfsExecutablePath;
                state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
                state = ValidateGitLfsVersion(state);
            }
            return(state);
        }
示例#28
0
 private GitInstallationState FindGitLfs(GitInstallationState state)
 {
     if (!state.GitLfsIsValid)
     {
         var gitLfsPath = new FindExecTask("git-lfs", environment, Token)
                          .Configure(processManager)
                          .Progress(progressReporter.UpdateProgress)
                          .Catch(e => true)
                          .RunSynchronously();
         state.GitLfsExecutablePath = gitLfsPath;
         state = ValidateGitLfsVersion(state);
         if (state.GitLfsIsValid)
         {
             state.GitLfsInstallationPath = state.GitLfsExecutablePath.Parent;
         }
     }
     return(state);
 }
示例#29
0
        private GitInstallationState VerifyZipFiles(GitInstallationState state)
        {
            var md5 = AssemblyResources.ToFile(ResourceType.Platform, "git.zip.md5", installDetails.ZipPath, environment);

            if (!md5.FileExists() || (installDetails.GitZipPath.FileExists() && !Utils.VerifyFileIntegrity(installDetails.GitZipPath, md5)))
            {
                installDetails.GitZipPath.DeleteIfExists();
            }
            state.GitZipExists = installDetails.GitZipPath.FileExists();

            md5 = AssemblyResources.ToFile(ResourceType.Platform, "git-lfs.zip.md5", installDetails.ZipPath, environment);
            // check whether the git-lfs zip file exists and is valid
            if (!md5.FileExists() || (installDetails.GitLfsZipPath.FileExists() && !Utils.VerifyFileIntegrity(installDetails.GitLfsZipPath, md5)))
            {
                installDetails.GitLfsZipPath.DeleteIfExists();
            }
            state.GitLfsZipExists = installDetails.GitLfsZipPath.FileExists();
            installationTask.UpdateProgress(20, 100);
            return(state);
        }
示例#30
0
        private GitInstallationState FindGit(GitInstallationState state)
        {
            if (!state.GitIsValid)
            {
                var gitPath = new FindExecTask(TaskManager,
                                               platform.ProcessManager.DefaultProcessEnvironment, platform.Environment,
                                               "git", cancellationToken)
                              .Configure(platform.ProcessManager)
                              .Progress(progressReporter.UpdateProgress)
                              .Catch(e => true)
                              .RunSynchronously();

                state.GitExecutablePath = gitPath;
                state = ValidateGitVersion(state);
                if (state.GitIsValid)
                {
                    state.GitInstallationPath = gitPath.Parent.Parent;
                }
            }
            return(state);
        }