diff --git a/src/GitHub.Api/Git/GitClient.cs b/src/GitHub.Api/Git/GitClient.cs index e3f8f5b7b..c7439b504 100644 --- a/src/GitHub.Api/Git/GitClient.cs +++ b/src/GitHub.Api/Git/GitClient.cs @@ -120,18 +120,29 @@ public ITask ValidateGitInstall(NPath path) 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 && + var endTask = new FuncTask(cancellationToken, + () => new ValidateGitInstallResult( gitVersion?.CompareTo(Constants.MinimumGitVersion) >= 0 && gitLfsVersion?.CompareTo(Constants.MinimumGitLfsVersion) >= 0, - gitVersion, gitLfsVersion) - ); + gitVersion, gitLfsVersion)); + + var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken).Configure(processManager, path); + + gitLfsVersionTask + .Then((result, version) => {return gitLfsVersion = version;}) + .Then(endTask, taskIsTopOfChain: true); + + gitLfsVersionTask.Then(endTask, TaskRunOptions.OnFailure, taskIsTopOfChain:true); + + var gitVersionTask = new GitVersionTask(cancellationToken).Configure(processManager, path); + + gitVersionTask + .Then((result, version) => { return gitVersion = version; }) + .Then(gitLfsVersionTask, taskIsTopOfChain: true); + + gitVersionTask.Then(endTask, TaskRunOptions.OnFailure, taskIsTopOfChain:true); + + return endTask; } public ITask Init(IOutputProcessor processor = null) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/GitPathView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/GitPathView.cs index b2031f83e..17128c4ac 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/GitPathView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/GitPathView.cs @@ -15,7 +15,9 @@ class GitPathView : Subview private const string BrowseButton = "..."; private const string GitInstallBrowseTitle = "Select git binary"; private const string ErrorInvalidPathMessage = "Invalid Path."; - private const string ErrorGettingSoftwareVersionMessage = "Error getting software versions."; + private const string ErrorValidatingGitPath = "Error validating Git Path."; + private const string ErrorGitNotFoundMessage = "Git not found."; + private const string ErrorGitLfsNotFoundMessage = "Git LFS not found."; private const string ErrorMinimumGitVersionMessageFormat = "Git version {0} found. Git version {1} is required."; private const string ErrorMinimumGitLfsVersionMessageFormat = "Git LFS version {0} found. Git LFS version {1} is required."; @@ -216,12 +218,12 @@ private void ValidateAndSetGitInstallPath(string value) gitVersionErrorMessage = null; GitClient.ValidateGitInstall(value.ToNPath()) - .ThenInUI((sucess, result) => + .FinallyInUI((success, exception, result) => { - if (!sucess) + if (!success) { - Logger.Trace(ErrorGettingSoftwareVersionMessage); - gitVersionErrorMessage = ErrorGettingSoftwareVersionMessage; + Logger.Trace(ErrorValidatingGitPath); + gitVersionErrorMessage = ErrorValidatingGitPath; } else if (!result.IsValid) { @@ -232,28 +234,39 @@ private void ValidateAndSetGitInstallPath(string value) var errorMessageStringBuilder = new StringBuilder(); - if (result.GitVersion < Constants.MinimumGitVersion) + if (result.GitVersion == null) { - errorMessageStringBuilder.AppendFormat(ErrorMinimumGitVersionMessageFormat, - result.GitVersion, Constants.MinimumGitVersion); + errorMessageStringBuilder.Append(ErrorGitNotFoundMessage); } - - if (result.GitLfsVersion < Constants.MinimumGitLfsVersion) + else if (result.GitLfsVersion == null) + { + errorMessageStringBuilder.Append(ErrorGitLfsNotFoundMessage); + } + else { - if (errorMessageStringBuilder.Length > 0) + if (result.GitVersion < Constants.MinimumGitVersion) { - errorMessageStringBuilder.Append(Environment.NewLine); + errorMessageStringBuilder.AppendFormat(ErrorMinimumGitVersionMessageFormat, + result.GitVersion, Constants.MinimumGitVersion); } - errorMessageStringBuilder.AppendFormat(ErrorMinimumGitLfsVersionMessageFormat, - result.GitLfsVersion, Constants.MinimumGitLfsVersion); + if (result.GitLfsVersion < Constants.MinimumGitLfsVersion) + { + if (errorMessageStringBuilder.Length > 0) + { + errorMessageStringBuilder.Append(Environment.NewLine); + } + + errorMessageStringBuilder.AppendFormat(ErrorMinimumGitLfsVersionMessageFormat, + result.GitLfsVersion, Constants.MinimumGitLfsVersion); + } } gitVersionErrorMessage = errorMessageStringBuilder.ToString(); } else { - Logger.Warning("Software versions meet minimums Git:{0} GitLfs:{1}", + Logger.Trace("Software versions meet minimums Git:{0} GitLfs:{1}", result.GitVersion, result.GitLfsVersion);