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

Commit 53529ed

Browse files
Capturing the situation where versions are not returned at all
1 parent fd531f4 commit 53529ed

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

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

Lines changed: 25 additions & 12 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

@@ -220,8 +222,8 @@ private void ValidateAndSetGitInstallPath(string value)
220222
{
221223
if (!sucess)
222224
{
223-
Logger.Trace(ErrorGettingSoftwareVersionMessage);
224-
gitVersionErrorMessage = ErrorGettingSoftwareVersionMessage;
225+
Logger.Trace(ErrorValidatingGitPath);
226+
gitVersionErrorMessage = ErrorValidatingGitPath;
225227
}
226228
else if (!result.IsValid)
227229
{
@@ -232,21 +234,32 @@ 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();

0 commit comments

Comments
 (0)