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

Commit fc7ec97

Browse files
Getting the right objects in place to run git config tasks during project setup
1 parent a038764 commit fc7ec97

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

src/GitHub.Api/ApplicationManagerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private async Task RunInternal()
103103
{
104104
await ThreadingHelper.SwitchToThreadAsync();
105105

106-
var gitSetup = new GitSetup(Environment, FileSystem, CancellationToken);
106+
var gitSetup = new GitSetup(Environment, ProcessManager, FileSystem, CancellationToken);
107107
var expectedPath = gitSetup.GitInstallationPath;
108108

109109
var setupDone = await gitSetup.SetupIfNeeded(

src/GitHub.Api/GitSetup.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,34 @@ namespace GitHub.Unity
66
{
77
class GitSetup
88
{
9-
private readonly IEnvironment environment;
109
private readonly CancellationToken cancellationToken;
10+
private readonly IEnvironment environment;
1111
private readonly GitInstaller gitInstaller;
12-
public NPath GitInstallationPath { get; private set; }
13-
public NPath GitExecutablePath { get; private set; }
12+
private readonly IProcessManager processManager;
1413

15-
public GitSetup(IEnvironment environment, IFileSystem fileSystem, CancellationToken cancellationToken)
14+
public GitSetup(IEnvironment environment, IProcessManager processManager, IFileSystem fileSystem,
15+
CancellationToken cancellationToken)
1616
{
1717
this.environment = environment;
18+
this.processManager = processManager;
1819
this.cancellationToken = cancellationToken;
1920
gitInstaller = new GitInstaller(environment, fileSystem, cancellationToken);
2021
GitInstallationPath = gitInstaller.PackageDestinationDirectory;
2122
GitExecutablePath = gitInstaller.GitDestinationPath;
2223
}
2324

24-
public Task<bool> SetupIfNeeded(IProgress<float> percentage = null, IProgress<long> timeRemaining = null)
25+
public async Task<bool> SetupIfNeeded(IProgress<float> percentage = null, IProgress<long> timeRemaining = null)
2526
{
26-
return gitInstaller.SetupIfNeeded(percentage, timeRemaining);
27+
var setupIfNeeded = await gitInstaller.SetupIfNeeded(percentage, timeRemaining);
28+
29+
var gitConfigGetTask = new GitConfigGetTask(environment, processManager,
30+
new TaskResultDispatcher<string>(s => { }), "credential.helper",
31+
GitConfigSource.Global);
32+
33+
return setupIfNeeded;
2734
}
35+
36+
public NPath GitInstallationPath { get; private set; }
37+
public NPath GitExecutablePath { get; private set; }
2838
}
29-
}
39+
}

src/IntegrationTests/BaseGitEnvironmentTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ protected void InitializeEnvironment(NPath repoPath)
1414
UnityProjectPath = repoPath
1515
};
1616

17-
var gitSetup = new GitSetup(Environment, FileSystem, CancellationToken.None);
17+
Platform = new Platform(Environment, FileSystem, new TestUIDispatcher());
18+
GitEnvironment = Platform.GitEnvironment;
19+
ProcessManager = new ProcessManager(Environment, GitEnvironment);
20+
21+
var gitSetup = new GitSetup(Environment, ProcessManager, FileSystem, CancellationToken.None);
1822
gitSetup.SetupIfNeeded().Wait();
1923

2024
Environment.GitExecutablePath = gitSetup.GitExecutablePath;
2125

2226
FileSystem.SetCurrentDirectory(repoPath);
23-
24-
Platform = new Platform(Environment, FileSystem, new TestUIDispatcher());
25-
GitEnvironment = Platform.GitEnvironment;
26-
ProcessManager = new ProcessManager(Environment, GitEnvironment);
2727
Platform.Initialize(ProcessManager);
2828

2929
Environment.UnityProjectPath = repoPath;

src/IntegrationTests/Git/GitSetupTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ public void InstallGit()
1414
{
1515
var environmentPath = NPath.CreateTempDirectory("integration-test-environment");
1616
var environment = new IntegrationTestEnvironment(SolutionDirectory, environmentPath);
17-
var gitSetup = new GitSetup(environment, FileSystem, CancellationToken.None);
17+
18+
var platform = new Platform(environment, FileSystem, new TestUIDispatcher());
19+
var gitEnvironment = platform.GitEnvironment;
20+
var processManager = new ProcessManager(environment, gitEnvironment);
21+
22+
var gitSetup = new GitSetup(environment, processManager, FileSystem, CancellationToken.None);
1823
var expectedPath = gitSetup.GitInstallationPath;
1924

2025
var setupDone = false;
@@ -51,10 +56,6 @@ public void InstallGit()
5156
setupDone.Should().BeFalse ();
5257
}
5358

54-
var platform = new Platform(environment, FileSystem, new TestUIDispatcher());
55-
var gitEnvironment = platform.GitEnvironment;
56-
var processManager = new ProcessManager(environment, gitEnvironment);
57-
5859
var gitBranches = processManager.GetGitBranches(TestRepoMasterDirtyUnsynchronized, environment.GitExecutablePath);
5960

6061
gitBranches.Should().BeEquivalentTo(

0 commit comments

Comments
 (0)