Esempio n. 1
0
        public ITask <ValidateGitInstallResult> ValidateGitInstall(NPath path, bool isCustomGit)
        {
            Version gitVersion    = null;
            Version gitLfsVersion = null;

            var endTask = new FuncTask <ValidateGitInstallResult>(cancellationToken,
                                                                  () => new ValidateGitInstallResult(
                                                                      gitVersion?.CompareTo(Constants.MinimumGitVersion) >= 0 &&
                                                                      gitLfsVersion?.CompareTo(Constants.MinimumGitLfsVersion) >= 0,
                                                                      gitVersion, gitLfsVersion));

            if (path.FileExists())
            {
                var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken)
                                        .Configure(processManager, path, dontSetupGit: isCustomGit);
                gitLfsVersionTask.OnEnd += (t, v, _, __) => gitLfsVersion = v;
                var gitVersionTask = new GitVersionTask(cancellationToken)
                                     .Configure(processManager, path, dontSetupGit: isCustomGit);
                gitVersionTask.OnEnd += (t, v, _, __) => gitVersion = v;

                gitVersionTask
                .Then(gitLfsVersionTask)
                .Finally(endTask);
            }
            return(endTask);
        }
Esempio n. 2
0
        public ITask <ValidateGitInstallResult> ValidateGitInstall(NPath path)
        {
            if (!path.FileExists())
            {
                return(new FuncTask <ValidateGitInstallResult>(TaskEx.FromResult(new ValidateGitInstallResult(false, null, null))));
            }

            Version gitVersion    = null;
            Version gitLfsVersion = null;

            var gitVersionTask    = new GitVersionTask(cancellationToken).Configure(processManager, path);
            var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken).Configure(processManager, path);

            return(gitVersionTask
                   .Then((result, version) => gitVersion = version)
                   .Then(gitLfsVersionTask)
                   .Then((result, version) => gitLfsVersion = version)
                   .Then(success => new ValidateGitInstallResult(success &&
                                                                 gitVersion?.CompareTo(Constants.MinimumGitVersion) >= 0 &&
                                                                 gitLfsVersion?.CompareTo(Constants.MinimumGitLfsVersion) >= 0,
                                                                 gitVersion, gitLfsVersion)
                         ));
        }