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

Commit 3f4fa09

Browse files
Functionality to validate the git install
1 parent abb3ae0 commit 3f4fa09

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

src/GitHub.Api/Git/GitClient.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace GitHub.Unity
99
interface IGitClient
1010
{
1111
Task<NPath> FindGitInstallation();
12-
bool ValidateGitInstall(NPath path);
12+
13+
ITask<bool> ValidateGitInstall(NPath path);
1314

1415
ITask Init(IOutputProcessor<string> processor = null);
1516

@@ -152,9 +153,40 @@ private async Task<NPath> LookForSystemGit()
152153
return path;
153154
}
154155

155-
public bool ValidateGitInstall(NPath path)
156+
public ITask<bool> ValidateGitInstall(NPath path)
156157
{
157-
return path.FileExists();
158+
if (!path.FileExists())
159+
{
160+
return new FuncTask<bool>(cancellationToken, () => false);
161+
}
162+
163+
SoftwareVersion? gitVersion = null;
164+
SoftwareVersion? gitLfsVersion = null;
165+
166+
var gitVersionTask = new GitVersionTask(cancellationToken);
167+
gitVersionTask.Configure(processManager, path.ToString(),
168+
gitVersionTask.ProcessArguments, environment.RepositoryPath);
169+
170+
var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken);
171+
gitLfsVersionTask.Configure(processManager, path.ToString(),
172+
gitLfsVersionTask.ProcessArguments, environment.RepositoryPath);
173+
174+
return gitVersionTask
175+
.Then((result, version) => { gitVersion = version; })
176+
.Then(gitLfsVersionTask)
177+
.Then((result, version) => {
178+
gitLfsVersion = version;
179+
}).Then(result => {
180+
if (result)
181+
{
182+
return gitVersion.HasValue &&
183+
gitVersion.Value >= new SoftwareVersion(2, 1, 0) &&
184+
gitLfsVersion.HasValue &&
185+
gitLfsVersion.Value >= new SoftwareVersion(2, 1, 0);
186+
}
187+
188+
return false;
189+
});
158190
}
159191

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

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,8 @@ private bool ValidateGitInstall(string path)
375375
{
376376
if (String.IsNullOrEmpty(path))
377377
return false;
378-
if (!GitClient.ValidateGitInstall(path.ToNPath()))
379-
{
380-
EditorUtility.DisplayDialog(GitInstallPickInvalidTitle, String.Format(GitInstallPickInvalidMessage, path),
381-
GitInstallPickInvalidOK);
382-
return false;
383-
}
384378

385-
return true;
379+
return path.ToNPath().FileExists();
386380
}
387381

388382
private bool OnIssuesGUI()

0 commit comments

Comments
 (0)