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

Commit 883ed16

Browse files
committed
GitInstallDetails is better off under GitInstaller
1 parent f2ee4ef commit 883ed16

File tree

4 files changed

+76
-76
lines changed

4 files changed

+76
-76
lines changed

src/GitHub.Api/Installer/GitInstaller.cs

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,6 @@
55

66
namespace GitHub.Unity
77
{
8-
class GitInstallDetails
9-
{
10-
public const string DefaultGitZipMd5Url = "https://ghfvs-installer.github.com/unity/portable_git/git.zip.MD5.txt";
11-
public const string DefaultGitZipUrl = "https://ghfvs-installer.github.com/unity/portable_git/git.zip";
12-
public const string DefaultGitLfsZipMd5Url = "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip.MD5.txt";
13-
public const string DefaultGitLfsZipUrl = "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip";
14-
15-
public const string GitExtractedMD5 = "e6cfc0c294a2312042f27f893dfc9c0a";
16-
public const string GitLfsExtractedMD5 = "36e3ae968b69fbf42dff72311040d24a";
17-
18-
public const string WindowsGitExecutableMD5 = "50570ed932559f294d1a1361801740b9";
19-
public const string MacGitExecutableMD5 = "";
20-
21-
public const string WindowsGitLfsExecutableMD5 = "177bb14d0c08f665a24f0d5516c3b080";
22-
public const string MacGitLfsExecutableMD5 = "f81a1a065a26a4123193e8fd96c561ad";
23-
24-
private const string PackageVersion = "f02737a78695063deace08e96d5042710d3e32db";
25-
private const string PackageName = "PortableGit";
26-
27-
private readonly bool onWindows;
28-
29-
public GitInstallDetails(NPath baseDataPath, bool onWindows)
30-
{
31-
this.onWindows = onWindows;
32-
33-
ZipPath = baseDataPath.Combine("downloads");
34-
ZipPath.EnsureDirectoryExists();
35-
36-
var gitInstallPath = baseDataPath.Combine(PackageNameWithVersion);
37-
GitInstallationPath = gitInstallPath;
38-
39-
if (onWindows)
40-
{
41-
GitExecutable += "git.exe";
42-
GitLfsExecutable += "git-lfs.exe";
43-
44-
GitExecutablePath = gitInstallPath.Combine("cmd", GitExecutable);
45-
}
46-
else
47-
{
48-
GitExecutable = "git";
49-
GitLfsExecutable = "git-lfs";
50-
51-
GitExecutablePath = gitInstallPath.Combine("bin", GitExecutable);
52-
}
53-
54-
GitLfsExecutablePath = GetGitLfsExecutablePath(gitInstallPath);
55-
}
56-
57-
public NPath GetGitLfsExecutablePath(NPath gitInstallRoot)
58-
{
59-
return onWindows
60-
? gitInstallRoot.Combine("mingw32", "libexec", "git-core", GitLfsExecutable)
61-
: gitInstallRoot.Combine("libexec", "git-core", GitLfsExecutable);
62-
}
63-
64-
public NPath ZipPath { get; }
65-
public NPath GitInstallationPath { get; }
66-
public string GitExecutable { get; }
67-
public NPath GitExecutablePath { get; }
68-
public string GitLfsExecutable { get; }
69-
public NPath GitLfsExecutablePath { get; }
70-
public UriString GitZipMd5Url { get; set; } = DefaultGitZipMd5Url;
71-
public UriString GitZipUrl { get; set; } = DefaultGitZipUrl;
72-
public UriString GitLfsZipMd5Url { get; set; } = DefaultGitLfsZipMd5Url;
73-
public UriString GitLfsZipUrl { get; set; } = DefaultGitLfsZipUrl;
74-
public string PackageNameWithVersion => PackageName + "_" + PackageVersion;
75-
}
76-
778
class GitInstaller
789
{
7910
private static readonly ILogging Logger = LogHelper.GetLogger<GitInstaller>();
@@ -238,5 +169,74 @@ private bool IsGitExtracted()
238169
Logger.Trace("Git Present");
239170
return true;
240171
}
172+
173+
public class GitInstallDetails
174+
{
175+
public const string DefaultGitZipMd5Url = "https://ghfvs-installer.github.com/unity/portable_git/git.zip.MD5.txt";
176+
public const string DefaultGitZipUrl = "https://ghfvs-installer.github.com/unity/portable_git/git.zip";
177+
public const string DefaultGitLfsZipMd5Url = "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip.MD5.txt";
178+
public const string DefaultGitLfsZipUrl = "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip";
179+
180+
public const string GitExtractedMD5 = "e6cfc0c294a2312042f27f893dfc9c0a";
181+
public const string GitLfsExtractedMD5 = "36e3ae968b69fbf42dff72311040d24a";
182+
183+
public const string WindowsGitExecutableMD5 = "50570ed932559f294d1a1361801740b9";
184+
public const string MacGitExecutableMD5 = "";
185+
186+
public const string WindowsGitLfsExecutableMD5 = "177bb14d0c08f665a24f0d5516c3b080";
187+
public const string MacGitLfsExecutableMD5 = "f81a1a065a26a4123193e8fd96c561ad";
188+
189+
private const string PackageVersion = "f02737a78695063deace08e96d5042710d3e32db";
190+
private const string PackageName = "PortableGit";
191+
192+
private readonly bool onWindows;
193+
194+
public GitInstallDetails(NPath baseDataPath, bool onWindows)
195+
{
196+
this.onWindows = onWindows;
197+
198+
ZipPath = baseDataPath.Combine("downloads");
199+
ZipPath.EnsureDirectoryExists();
200+
201+
var gitInstallPath = baseDataPath.Combine(PackageNameWithVersion);
202+
GitInstallationPath = gitInstallPath;
203+
204+
if (onWindows)
205+
{
206+
GitExecutable += "git.exe";
207+
GitLfsExecutable += "git-lfs.exe";
208+
209+
GitExecutablePath = gitInstallPath.Combine("cmd", GitExecutable);
210+
}
211+
else
212+
{
213+
GitExecutable = "git";
214+
GitLfsExecutable = "git-lfs";
215+
216+
GitExecutablePath = gitInstallPath.Combine("bin", GitExecutable);
217+
}
218+
219+
GitLfsExecutablePath = GetGitLfsExecutablePath(gitInstallPath);
220+
}
221+
222+
public NPath GetGitLfsExecutablePath(NPath gitInstallRoot)
223+
{
224+
return onWindows
225+
? gitInstallRoot.Combine("mingw32", "libexec", "git-core", GitLfsExecutable)
226+
: gitInstallRoot.Combine("libexec", "git-core", GitLfsExecutable);
227+
}
228+
229+
public NPath ZipPath { get; }
230+
public NPath GitInstallationPath { get; }
231+
public string GitExecutable { get; }
232+
public NPath GitExecutablePath { get; }
233+
public string GitLfsExecutable { get; }
234+
public NPath GitLfsExecutablePath { get; }
235+
public UriString GitZipMd5Url { get; set; } = DefaultGitZipMd5Url;
236+
public UriString GitZipUrl { get; set; } = DefaultGitZipUrl;
237+
public UriString GitLfsZipMd5Url { get; set; } = DefaultGitLfsZipMd5Url;
238+
public UriString GitLfsZipUrl { get; set; } = DefaultGitLfsZipUrl;
239+
public string PackageNameWithVersion => PackageName + "_" + PackageVersion;
241240
}
242241
}
242+
}

src/tests/IntegrationTests/BasePlatformIntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected void InitializePlatform(NPath repoPath, NPath environmentPath, bool en
3030
var autoResetEvent = new AutoResetEvent(false);
3131

3232
var applicationDataPath = Environment.GetSpecialFolder(System.Environment.SpecialFolder.LocalApplicationData).ToNPath();
33-
var installDetails = new GitInstallDetails(applicationDataPath, true);
33+
var installDetails = new GitInstaller.GitInstallDetails(applicationDataPath, true);
3434

3535
var zipArchivesPath = TestBasePath.Combine("ZipArchives").CreateDirectory();
3636
var gitArchivePath = AssemblyResources.ToFile(ResourceType.Platform, "git.zip", zipArchivesPath, Environment);

src/tests/IntegrationTests/Installer/GitInstallerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public void GitInstallTest()
4040
{
4141
var gitInstallationPath = TestBasePath.Combine("GitInstall").CreateDirectory();
4242

43-
var installDetails = new GitInstallDetails(gitInstallationPath, DefaultEnvironment.OnWindows)
43+
var installDetails = new GitInstaller.GitInstallDetails(gitInstallationPath, DefaultEnvironment.OnWindows)
4444
{
45-
GitZipMd5Url = $"http://localhost:{server.Port}/{new UriString(GitInstallDetails.DefaultGitZipMd5Url).Filename}",
46-
GitZipUrl = $"http://localhost:{server.Port}/{new UriString(GitInstallDetails.DefaultGitZipUrl).Filename}",
47-
GitLfsZipMd5Url = $"http://localhost:{server.Port}/{new UriString(GitInstallDetails.DefaultGitLfsZipMd5Url).Filename}",
48-
GitLfsZipUrl = $"http://localhost:{server.Port}/{new UriString(GitInstallDetails.DefaultGitLfsZipUrl).Filename}",
45+
GitZipMd5Url = $"http://localhost:{server.Port}/{new UriString(GitInstaller.GitInstallDetails.DefaultGitZipMd5Url).Filename}",
46+
GitZipUrl = $"http://localhost:{server.Port}/{new UriString(GitInstaller.GitInstallDetails.DefaultGitZipUrl).Filename}",
47+
GitLfsZipMd5Url = $"http://localhost:{server.Port}/{new UriString(GitInstaller.GitInstallDetails.DefaultGitLfsZipMd5Url).Filename}",
48+
GitLfsZipUrl = $"http://localhost:{server.Port}/{new UriString(GitInstaller.GitInstallDetails.DefaultGitLfsZipUrl).Filename}",
4949
};
5050

5151
TestBasePath.Combine("git").CreateDirectory();

src/tests/IntegrationTests/UnzipTaskTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public async Task UnzipWorks()
2727
var extractedPath = TestBasePath.Combine("gitlfs_zip_extracted").CreateDirectory();
2828

2929
var unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath,
30-
Environment.FileSystem, GitInstallDetails.GitLfsExtractedMD5);
30+
Environment.FileSystem, GitInstaller.GitInstallDetails.GitLfsExtractedMD5);
3131

3232
await unzipTask.StartAwait();
3333

0 commit comments

Comments
 (0)