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

Commit c0b4bb4

Browse files
authored
Merge pull request #38 from github-for-unity/lfs-2.2
Bump lfs to 2.2
2 parents 8181952 + 20f21f6 commit c0b4bb4

File tree

9 files changed

+43
-72
lines changed

9 files changed

+43
-72
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public virtual async Task Run(bool firstRun)
5555
var progress = new ProgressReport();
5656

5757
var gitClient = new GitClient(Environment, ProcessManager, Platform.CredentialManager, TaskManager);
58-
var gitSetup = new GitSetup(Environment, CancellationToken);
58+
var gitSetup = new GitInstaller(Environment, CancellationToken);
5959
var expectedPath = gitSetup.GitInstallationPath;
6060
var setupDone = await gitSetup.SetupIfNeeded(progress.Percentage, progress.Remaining);
6161
if (setupDone)

src/GitHub.Api/Git/GitSetup.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
<Compile Include="Events\RepositoryWatcher.cs" />
111111
<Compile Include="Extensions\FileSystemExtensions.cs" />
112112
<Compile Include="Extensions\StreamExtensions.cs" />
113-
<Compile Include="Git\GitSetup.cs" />
114113
<Compile Include="Git\GitFileStatus.cs" />
115114
<Compile Include="Git\GitLock.cs" />
116115
<Compile Include="Git\GitObjectFactory.cs" />

src/GitHub.Api/Installer/GitInstaller.cs

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ namespace GitHub.Unity
66
{
77
class GitInstaller : IGitInstaller
88
{
9-
public const string GitLfsExecutableMD5 = "63700E111EF68EE1AD866C2C4373B68D";
9+
public const string WindowsGitLfsExecutableMD5 = "7cfa21e5e9f9819a7cb0c317b0be1c5b";
10+
public const string MacGitLfsExecutableMD5 = "54f586df05a4b80feae4fabed10d8e95";
1011

1112
private const string PortableGitExpectedVersion = "f02737a78695063deace08e96d5042710d3e32db";
1213
private const string PackageName = "PortableGit";
@@ -40,7 +41,7 @@ public GitInstaller(IEnvironment environment, IZipHelper sharpZipLibHelper, Canc
4041
: ZipHelper.ExtractZipFile;
4142

4243

43-
PackageDestinationDirectory = environment.GetSpecialFolder(Environment.SpecialFolder.LocalApplicationData)
44+
GitInstallationPath = environment.GetSpecialFolder(Environment.SpecialFolder.LocalApplicationData)
4445
.ToNPath().Combine(ApplicationInfo.ApplicationName, PackageNameWithVersion);
4546
var gitExecutable = "git";
4647
var gitLfsExecutable = "git-lfs";
@@ -52,21 +53,21 @@ public GitInstaller(IEnvironment environment, IZipHelper sharpZipLibHelper, Canc
5253
GitLfsExecutable = gitLfsExecutable;
5354
GitExecutable = gitExecutable;
5455

55-
GitDestinationPath = PackageDestinationDirectory;
56+
GitExecutablePath = GitInstallationPath;
5657
if (DefaultEnvironment.OnWindows)
57-
GitDestinationPath = GitDestinationPath.Combine("cmd");
58+
GitExecutablePath = GitExecutablePath.Combine("cmd");
5859
else
59-
GitDestinationPath = GitDestinationPath.Combine("bin");
60-
GitDestinationPath = GitDestinationPath.Combine(GitExecutable);
60+
GitExecutablePath = GitExecutablePath.Combine("bin");
61+
GitExecutablePath = GitExecutablePath.Combine(GitExecutable);
6162

62-
GitLfsDestinationPath = PackageDestinationDirectory;
63+
GitLfsExecutablePath = GitInstallationPath;
6364

6465
if (DefaultEnvironment.OnWindows)
6566
{
66-
GitLfsDestinationPath = GitLfsDestinationPath.Combine("mingw32");
67+
GitLfsExecutablePath = GitLfsExecutablePath.Combine("mingw32");
6768
}
6869

69-
GitLfsDestinationPath = GitLfsDestinationPath.Combine("libexec", "git-core", GitLfsExecutable);
70+
GitLfsExecutablePath = GitLfsExecutablePath.Combine("libexec", "git-core", GitLfsExecutable);
7071
}
7172

7273
public bool IsExtracted()
@@ -76,9 +77,9 @@ public bool IsExtracted()
7677

7778
private bool IsPortableGitExtracted()
7879
{
79-
if (!GitDestinationPath.FileExists())
80+
if (!GitExecutablePath.FileExists())
8081
{
81-
logger.Trace("{0} not installed yet", GitDestinationPath);
82+
logger.Trace("{0} not installed yet", GitExecutablePath);
8283
return false;
8384
}
8485

@@ -89,18 +90,18 @@ private bool IsPortableGitExtracted()
8990

9091
public bool IsGitLfsExtracted()
9192
{
92-
if (!GitLfsDestinationPath.FileExists())
93+
if (!GitLfsExecutablePath.FileExists())
9394
{
94-
logger.Trace("{0} not installed yet", GitLfsDestinationPath);
95+
logger.Trace("{0} not installed yet", GitLfsExecutablePath);
9596
return false;
9697
}
9798

98-
var calculateMd5 = environment.FileSystem.CalculateMD5(GitLfsDestinationPath);
99+
var calculateMd5 = environment.FileSystem.CalculateMD5(GitLfsExecutablePath);
99100
logger.Trace("GitLFS MD5: {0}", calculateMd5);
100-
101-
if (calculateMd5 != GitLfsExecutableMD5)
101+
var md5 = environment.IsWindows ? WindowsGitLfsExecutableMD5 : MacGitLfsExecutableMD5;
102+
if (String.Compare(calculateMd5, md5, true) != 0)
102103
{
103-
logger.Trace("{0} has incorrect MD5", GitDestinationPath);
104+
logger.Trace("{0} has incorrect MD5", GitExecutablePath);
104105
return false;
105106
}
106107

@@ -156,7 +157,7 @@ public Task<bool> SetupGitIfNeeded(NPath tempPath, IProgress<float> zipFileProgr
156157

157158
if (IsPortableGitExtracted())
158159
{
159-
logger.Trace("Already extracted {0}, returning", PackageDestinationDirectory);
160+
logger.Trace("Already extracted {0}, returning", GitInstallationPath);
160161
return TaskEx.FromResult(true);
161162
}
162163

@@ -196,16 +197,16 @@ public Task<bool> SetupGitIfNeeded(NPath tempPath, IProgress<float> zipFileProgr
196197

197198
try
198199
{
199-
PackageDestinationDirectory.DeleteIfExists();
200-
PackageDestinationDirectory.EnsureParentDirectoryExists();
200+
GitInstallationPath.DeleteIfExists();
201+
GitInstallationPath.EnsureParentDirectoryExists();
201202

202-
logger.Trace("Moving \"{0}\" to \"{1}\"", unzipPath, PackageDestinationDirectory);
203+
logger.Trace("Moving \"{0}\" to \"{1}\"", unzipPath, GitInstallationPath);
203204

204-
unzipPath.Move(PackageDestinationDirectory);
205+
unzipPath.Move(GitInstallationPath);
205206
}
206207
catch (Exception ex)
207208
{
208-
logger.Error(ex, "Error Moving \"{0}\" to \"{1}\"", tempPath, PackageDestinationDirectory);
209+
logger.Error(ex, "Error Moving \"{0}\" to \"{1}\"", tempPath, GitInstallationPath);
209210
return TaskEx.FromResult(false);
210211
}
211212
unzipPath.DeleteIfExists();
@@ -221,7 +222,7 @@ public Task<bool> SetupGitLfsIfNeeded(NPath tempPath, IProgress<float> zipFilePr
221222

222223
if (IsGitLfsExtracted())
223224
{
224-
logger.Trace("Already extracted {0}, returning", GitLfsDestinationPath);
225+
logger.Trace("Already extracted {0}, returning", GitLfsExecutablePath);
225226
return TaskEx.FromResult(false);
226227
}
227228

@@ -262,13 +263,13 @@ public Task<bool> SetupGitLfsIfNeeded(NPath tempPath, IProgress<float> zipFilePr
262263
try
263264
{
264265
var unzippedGitLfsExecutablePath = unzipPath.Combine(GitLfsExecutable);
265-
logger.Trace("Copying \"{0}\" to \"{1}\"", unzippedGitLfsExecutablePath, GitLfsDestinationPath);
266+
logger.Trace("Copying \"{0}\" to \"{1}\"", unzippedGitLfsExecutablePath, GitLfsExecutablePath);
266267

267-
unzippedGitLfsExecutablePath.Copy(GitLfsDestinationPath);
268+
unzippedGitLfsExecutablePath.Copy(GitLfsExecutablePath);
268269
}
269270
catch (Exception ex)
270271
{
271-
logger.Error(ex, "Error Copying git-lfs Source:\"{0}\" Destination:\"{1}\"", unzipPath, GitLfsDestinationPath);
272+
logger.Error(ex, "Error Copying git-lfs Source:\"{0}\" Destination:\"{1}\"", unzipPath, GitLfsExecutablePath);
272273
return TaskEx.FromResult(false);
273274
}
274275
unzipPath.DeleteIfExists();
@@ -280,11 +281,11 @@ private NPath GetTemporaryPath()
280281
return NPath.CreateTempDirectory(TempPathPrefix);
281282
}
282283

283-
public NPath PackageDestinationDirectory { get; private set; }
284+
public NPath GitInstallationPath { get; private set; }
284285

285-
public NPath GitLfsDestinationPath { get; private set; }
286+
public NPath GitLfsExecutablePath { get; private set; }
286287

287-
public NPath GitDestinationPath { get; private set; }
288+
public NPath GitExecutablePath { get; private set; }
288289
public string PackageNameWithVersion => PackageName + "_" + PortableGitExpectedVersion;
289290

290291
private string GitLfsExecutable { get; set; }

src/GitHub.Api/Installer/IGitInstaller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace GitHub.Unity
77
interface IGitInstaller
88
{
99
bool IsExtracted();
10-
NPath PackageDestinationDirectory { get; }
10+
NPath GitInstallationPath { get; }
1111
string PackageNameWithVersion { get; }
1212
}
1313
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:68434557f74b3d22406ee18e4032fecbf743865378830b6fef283ac022a6e00c
3-
size 2617036
2+
oid sha256:749d4f91993eb4526f3667e524b9902e2d909fcd2a9ea8ee6025177eb16817f0
3+
size 2736142
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:04b6e46a033a3cb289c7a3bfedd976e28eeeb50f6f399b528d6dafd19a4ae11f
3-
size 2674166
2+
oid sha256:9aac2fdc3d1527ee6c796e4364eafeacbbeefc38714a4df63fb7c8a1ec7bcff5
3+
size 2596848

src/tests/IntegrationTests/BaseGitEnvironmentTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected async Task<IEnvironment> Initialize(NPath repoPath, NPath environmentP
1616

1717
Environment = new IntegrationTestEnvironment(repoPath, SolutionDirectory, environmentPath, enableEnvironmentTrace);
1818

19-
var gitSetup = new GitSetup(Environment, TaskManager.Token);
19+
var gitSetup = new GitInstaller(Environment, TaskManager.Token);
2020
await gitSetup.SetupIfNeeded();
2121
Environment.GitExecutablePath = gitSetup.GitExecutablePath;
2222

src/tests/IntegrationTests/Git/GitSetupTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ public async Task InstallGit()
1616
var environmentPath = NPath.CreateTempDirectory("integration-test-environment");
1717
var environment = await Initialize(TestRepoMasterDirtyUnsynchronized, environmentPath);
1818

19-
var gitSetup = new GitSetup(environment, TaskManager.Token);
19+
var gitSetup = new GitInstaller(environment, TaskManager.Token);
2020
var expectedPath = gitSetup.GitInstallationPath;
2121

2222
var setupDone = false;
2323
var percent = -1f;
2424
gitSetup.GitExecutablePath.FileExists().Should().BeFalse();
2525

26-
setupDone = await gitSetup.SetupIfNeeded(percentage: new Progress<float>(x => percent = x));
26+
setupDone = await gitSetup.SetupIfNeeded(new Progress<float>(x => percent = x));
2727

2828
if (environment.IsWindows)
2929
{
@@ -42,9 +42,9 @@ public async Task InstallGit()
4242
gitLfsDestinationPath.FileExists().Should().BeTrue();
4343

4444
var calculateMd5 = NPath.FileSystem.CalculateMD5(gitLfsDestinationPath);
45-
GitInstaller.GitLfsExecutableMD5.Should().Be(calculateMd5);
45+
Assert.IsTrue(string.Compare(calculateMd5, GitInstaller.WindowsGitLfsExecutableMD5, true) == 0);
4646

47-
setupDone = await gitSetup.SetupIfNeeded(percentage: new Progress<float>(x => percent = x));
47+
setupDone = await gitSetup.SetupIfNeeded(new Progress<float>(x => percent = x));
4848
setupDone.Should().BeFalse();
4949
}
5050
else
@@ -84,7 +84,7 @@ public void VerifyGitLfsBundle()
8484
gitLfsPath.Exists().Should().BeTrue();
8585

8686
var calculateMd5 = NPath.FileSystem.CalculateMD5(gitLfsPath);
87-
GitInstaller.GitLfsExecutableMD5.Should().Be(calculateMd5);
87+
Assert.IsTrue(string.Compare(calculateMd5, GitInstaller.WindowsGitLfsExecutableMD5, true) == 0);
8888
}
8989
}
9090
}

0 commit comments

Comments
 (0)