Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 85cd131

Browse files
Merge branch 'fixes/git-save-path-failure' into enhancements/reset-to-internal-git
2 parents 977b32e + ce8f75f commit 85cd131

File tree

2 files changed

+49
-25
lines changed

2 files changed

+49
-25
lines changed

src/GitHub.Api/Git/GitClient.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,29 @@ public ITask<ValidateGitInstallResult> ValidateGitInstall(NPath path)
120120
Version gitVersion = null;
121121
Version gitLfsVersion = null;
122122

123-
var gitVersionTask = new GitVersionTask(cancellationToken).Configure(processManager, path);
124-
var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken).Configure(processManager, path);
125-
126-
return gitVersionTask
127-
.Then((result, version) => gitVersion = version)
128-
.Then(gitLfsVersionTask)
129-
.Then((result, version) => gitLfsVersion = version)
130-
.Then(success => new ValidateGitInstallResult(success &&
123+
var endTask = new FuncTask<ValidateGitInstallResult>(cancellationToken,
124+
() => new ValidateGitInstallResult(
131125
gitVersion?.CompareTo(Constants.MinimumGitVersion) >= 0 &&
132126
gitLfsVersion?.CompareTo(Constants.MinimumGitLfsVersion) >= 0,
133-
gitVersion, gitLfsVersion)
134-
);
127+
gitVersion, gitLfsVersion));
128+
129+
var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken).Configure(processManager, path);
130+
131+
gitLfsVersionTask
132+
.Then((result, version) => {return gitLfsVersion = version;})
133+
.Then(endTask, taskIsTopOfChain: true);
134+
135+
gitLfsVersionTask.Then(endTask, TaskRunOptions.OnFailure, taskIsTopOfChain:true);
136+
137+
var gitVersionTask = new GitVersionTask(cancellationToken).Configure(processManager, path);
138+
139+
gitVersionTask
140+
.Then((result, version) => { return gitVersion = version; })
141+
.Then(gitLfsVersionTask, taskIsTopOfChain: true);
142+
143+
gitVersionTask.Then(endTask, TaskRunOptions.OnFailure, taskIsTopOfChain:true);
144+
145+
return endTask;
135146
}
136147

137148
public ITask Init(IOutputProcessor<string> processor = null)

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/GitPathView.cs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class GitPathView : Subview
1515
private const string BrowseButton = "...";
1616
private const string GitInstallBrowseTitle = "Select git binary";
1717
private const string ErrorInvalidPathMessage = "Invalid Path.";
18-
private const string ErrorGettingSoftwareVersionMessage = "Error getting software versions.";
18+
private const string ErrorValidatingGitPath = "Error validating Git Path.";
19+
private const string ErrorGitNotFoundMessage = "Git not found.";
20+
private const string ErrorGitLfsNotFoundMessage = "Git LFS not found.";
1921
private const string ErrorMinimumGitVersionMessageFormat = "Git version {0} found. Git version {1} is required.";
2022
private const string ErrorMinimumGitLfsVersionMessageFormat = "Git LFS version {0} found. Git LFS version {1} is required.";
2123

@@ -216,12 +218,12 @@ private void ValidateAndSetGitInstallPath(string value)
216218
gitVersionErrorMessage = null;
217219

218220
GitClient.ValidateGitInstall(value.ToNPath())
219-
.ThenInUI((sucess, result) =>
221+
.FinallyInUI((success, exception, result) =>
220222
{
221-
if (!sucess)
223+
if (!success)
222224
{
223-
Logger.Trace(ErrorGettingSoftwareVersionMessage);
224-
gitVersionErrorMessage = ErrorGettingSoftwareVersionMessage;
225+
Logger.Trace(ErrorValidatingGitPath);
226+
gitVersionErrorMessage = ErrorValidatingGitPath;
225227
}
226228
else if (!result.IsValid)
227229
{
@@ -232,28 +234,39 @@ private void ValidateAndSetGitInstallPath(string value)
232234

233235
var errorMessageStringBuilder = new StringBuilder();
234236

235-
if (result.GitVersion < Constants.MinimumGitVersion)
237+
if (result.GitVersion == null)
236238
{
237-
errorMessageStringBuilder.AppendFormat(ErrorMinimumGitVersionMessageFormat,
238-
result.GitVersion, Constants.MinimumGitVersion);
239+
errorMessageStringBuilder.Append(ErrorGitNotFoundMessage);
239240
}
240-
241-
if (result.GitLfsVersion < Constants.MinimumGitLfsVersion)
241+
else if (result.GitLfsVersion == null)
242+
{
243+
errorMessageStringBuilder.Append(ErrorGitLfsNotFoundMessage);
244+
}
245+
else
242246
{
243-
if (errorMessageStringBuilder.Length > 0)
247+
if (result.GitVersion < Constants.MinimumGitVersion)
244248
{
245-
errorMessageStringBuilder.Append(Environment.NewLine);
249+
errorMessageStringBuilder.AppendFormat(ErrorMinimumGitVersionMessageFormat,
250+
result.GitVersion, Constants.MinimumGitVersion);
246251
}
247252

248-
errorMessageStringBuilder.AppendFormat(ErrorMinimumGitLfsVersionMessageFormat,
249-
result.GitLfsVersion, Constants.MinimumGitLfsVersion);
253+
if (result.GitLfsVersion < Constants.MinimumGitLfsVersion)
254+
{
255+
if (errorMessageStringBuilder.Length > 0)
256+
{
257+
errorMessageStringBuilder.Append(Environment.NewLine);
258+
}
259+
260+
errorMessageStringBuilder.AppendFormat(ErrorMinimumGitLfsVersionMessageFormat,
261+
result.GitLfsVersion, Constants.MinimumGitLfsVersion);
262+
}
250263
}
251264

252265
gitVersionErrorMessage = errorMessageStringBuilder.ToString();
253266
}
254267
else
255268
{
256-
Logger.Warning("Software versions meet minimums Git:{0} GitLfs:{1}",
269+
Logger.Trace("Software versions meet minimums Git:{0} GitLfs:{1}",
257270
result.GitVersion,
258271
result.GitLfsVersion);
259272

0 commit comments

Comments
 (0)