Skip to content

Commit d7fc5ef

Browse files
author
Nelson Vides
committed
Updated LibGit2Sharp to version v0.24.0
API changed: -> repository.commit() now mandates 'author' and 'commiter' as two distinct parameters. I pass into both the same value by default. -> repository.Stage() passes to the static class 'Commands' taking the repo as a first parameters. -> repository.Pull() undergoes the same change -> repository.Checkout() also -> repository.Remove() also -> repository.Fetch() takes the biggest changes. -It now requires by default a refSpec. As we will usually fetch everything, I hardcoded on the code the classic "+refs/heads/*:refs/remotes/origin/*". -It also requires a logMessage, which I hardoced empty ("") -> repository.Branches[branch].Remote changes as well. Now this collection moves to the .Network class member of the repository, as repo.Network.Remotes[branch] Changes to be committed: modified: RetailCoder.VBE/Rubberduck.csproj modified: RetailCoder.VBE/packages.config modified: Rubberduck.SourceControl/GitProvider.cs modified: Rubberduck.SourceControl/Rubberduck.SourceControl.csproj new file: Rubberduck.SourceControl/_SourceControlClassDiagram.cd modified: Rubberduck.SourceControl/packages.config modified: RubberduckTests/RubberduckTests.csproj
1 parent bed752c commit d7fc5ef

File tree

7 files changed

+286
-23
lines changed

7 files changed

+286
-23
lines changed

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" />
34
<Import Project="..\packages\Antlr4.4.3.0\build\Antlr4.props" Condition="Exists('..\packages\Antlr4.4.3.0\build\Antlr4.props')" />
45
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
56
<PropertyGroup>
@@ -12,7 +13,8 @@
1213
<AssemblyName>Rubberduck</AssemblyName>
1314
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1415
<FileAlignment>512</FileAlignment>
15-
<NuGetPackageImportStamp>480c0557</NuGetPackageImportStamp>
16+
<NuGetPackageImportStamp>
17+
</NuGetPackageImportStamp>
1618
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
1719
<RestorePackages>true</RestorePackages>
1820
</PropertyGroup>
@@ -256,9 +258,9 @@
256258
<Reference Include="Infralution.Localization.Wpf">
257259
<HintPath>..\libs\Infralution.Localization.Wpf.dll</HintPath>
258260
</Reference>
259-
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, processorArchitecture=MSIL">
261+
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
260262
<SpecificVersion>False</SpecificVersion>
261-
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll</HintPath>
263+
<HintPath>..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
262264
</Reference>
263265
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
264266
<HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
@@ -1485,6 +1487,7 @@
14851487
<Error Condition="!Exists('..\packages\Antlr4.4.3.0\build\Antlr4.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Antlr4.4.3.0\build\Antlr4.props'))" />
14861488
<Error Condition="!Exists('..\packages\Antlr4.4.3.0\build\Antlr4.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Antlr4.4.3.0\build\Antlr4.targets'))" />
14871489
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
1490+
<Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props'))" />
14881491
</Target>
14891492
<Import Project="..\packages\Antlr4.4.3.0\build\Antlr4.targets" Condition="Exists('..\packages\Antlr4.4.3.0\build\Antlr4.targets')" />
14901493
<PropertyGroup>

RetailCoder.VBE/packages.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<package id="Castle.Windsor" version="4.0.0" targetFramework="net45" />
88
<package id="EasyHook" version="2.7.6270" targetFramework="net45" />
99
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net45" />
10+
<package id="LibGit2Sharp" version="0.24.0" targetFramework="net45" />
11+
<package id="LibGit2Sharp.NativeBinaries" version="1.0.185" targetFramework="net45" />
1012
<package id="NLog" version="4.0.1" targetFramework="net45" />
1113
<package id="NLog.Schema" version="4.0.1" targetFramework="net45" />
1214
<package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />

Rubberduck.SourceControl/GitProvider.cs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,16 @@ public override IRepository InitVBAProject(string directory)
185185
var status = repo.RetrieveStatus(new StatusOptions {DetectRenamesInWorkDir = true});
186186
foreach (var stat in status.Untracked)
187187
{
188-
repo.Stage(stat.FilePath);
188+
// repo.Stage(stat.FilePath); //deprecated from LibGit2Sharp v0.24
189+
LibGit2Sharp.Commands.Stage(repo, stat.FilePath);
189190
}
190191

191192
try
192193
{
193194
//The default behavior of LibGit2Sharp.Repo.Commit is to throw an exception if no signature is found,
194195
// but BuildSignature() does not throw if a signature is not found, it returns "unknown" instead.
195196
// so we pass a signature that won't throw along to the commit.
196-
repo.Commit("Initial Commit", GetSignature(repo));
197+
repo.Commit("Initial Commit", GetSignature(repo), GetSignature(repo));
197198
}
198199
catch(LibGit2SharpException ex)
199200
{
@@ -246,7 +247,15 @@ public override void Fetch([Optional] string remoteName)
246247

247248
if (remote != null)
248249
{
249-
_repo.Network.Fetch(remote);
250+
//_repo.Network.Fetch(remote); // deprecated on LibGit2Sharp from v0.24.0
251+
/*
252+
* The new functionality requires a refSpec.
253+
* As I suppose we're just tracking by default the whole remote,
254+
* then I choose to hardcode the refSpec here:
255+
*/
256+
// NOTE: hardcoded string
257+
IEnumerable<string> refSpec = new List<string>() {"+refs/heads/*:refs/remotes/origin/*"};
258+
LibGit2Sharp.Commands.Fetch(_repo, remoteName, refSpec, null,"");
250259
}
251260

252261
RequeryUnsyncedCommits();
@@ -270,7 +279,8 @@ public override void Pull()
270279
};
271280

272281
var signature = GetSignature();
273-
_repo.Network.Pull(signature, options);
282+
//_repo.Network.Pull(signature, options); // deprecated on LibGit2Sharp from v0.24.0
283+
LibGit2Sharp.Commands.Pull(_repo, signature, options);
274284

275285
base.Pull();
276286

@@ -289,7 +299,7 @@ public override void Commit(string message)
289299
//The default behavior of LibGit2Sharp.Repo.Commit is to throw an exception if no signature is found,
290300
// but BuildSignature() does not throw if a signature is not found, it returns "unknown" instead.
291301
// so we pass a signature that won't throw along to the commit.
292-
_repo.Commit(message, GetSignature());
302+
_repo.Commit(message, GetSignature(), GetSignature());
293303
}
294304
catch (LibGit2SharpException ex)
295305
{
@@ -301,7 +311,8 @@ public override void Stage(string filePath)
301311
{
302312
try
303313
{
304-
_repo.Stage(filePath);
314+
// _repo.Stage(filePath); // deprecated on LibGit2Sharp from v0.24.0
315+
LibGit2Sharp.Commands.Stage(_repo, filePath);
305316
}
306317
catch (LibGit2SharpException ex)
307318
{
@@ -313,7 +324,8 @@ public override void Stage(IEnumerable<string> filePaths)
313324
{
314325
try
315326
{
316-
_repo.Stage(filePaths);
327+
//_repo.Stage(filePaths); // deprecated on LibGit2Sharp from v0.24.0
328+
LibGit2Sharp.Commands.Stage(_repo, filePaths);
317329
}
318330
catch (LibGit2SharpException ex)
319331
{
@@ -348,7 +360,8 @@ public override void Checkout(string branch)
348360
{
349361
try
350362
{
351-
_repo.Checkout(_repo.Branches[branch]);
363+
//_repo.Checkout(_repo.Branches[branch]); // deprecated on LibGit2Sharp from v0.24.0
364+
LibGit2Sharp.Commands.Checkout(_repo, branch);
352365
base.Checkout(branch);
353366

354367
RequeryUnsyncedCommits();
@@ -364,7 +377,8 @@ public override void CreateBranch(string branch)
364377
try
365378
{
366379
_repo.CreateBranch(branch);
367-
_repo.Checkout(branch);
380+
//_repo.Checkout(branch); // deprecated on LibGit2Sharp from v0.24.0
381+
LibGit2Sharp.Commands.Checkout(_repo,branch);
368382

369383
RequeryUnsyncedCommits();
370384
}
@@ -379,7 +393,8 @@ public override void CreateBranch(string sourceBranch, string branch)
379393
try
380394
{
381395
_repo.CreateBranch(branch, _repo.Branches[sourceBranch].Commits.Last());
382-
_repo.Checkout(branch);
396+
//_repo.Checkout(branch); // deprecated on LibGit2Sharp from v0.24.0
397+
LibGit2Sharp.Commands.Checkout(_repo, branch);
383398

384399
RequeryUnsyncedCommits();
385400
}
@@ -417,7 +432,8 @@ public override void Unpublish(string branch)
417432
{
418433
try
419434
{
420-
var remote = _repo.Branches[branch].Remote;
435+
//var remote = _repo.Branches[branch].Remote; // deprecated on LibGit2Sharp from v0.24.0
436+
var remote = _repo.Network.Remotes[branch];
421437

422438
_repo.Branches.Update(_repo.Branches[branch], b => b.Remote = remote.Name,
423439
b => b.TrackedBranch = null, b => b.UpstreamBranch = null);
@@ -463,7 +479,8 @@ public override void AddFile(string filePath)
463479
try
464480
{
465481
// https://github.com/libgit2/libgit2sharp/wiki/Git-add
466-
_repo.Stage(filePath);
482+
//_repo.Stage(filePath); // deprecated on LibGit2Sharp from v0.24.0
483+
LibGit2Sharp.Commands.Stage(_repo, filePath);
467484
}
468485
catch (LibGit2SharpException ex)
469486
{
@@ -481,7 +498,8 @@ public override void RemoveFile(string filePath, bool removeFromWorkingDirectory
481498
try
482499
{
483500
NotifyExternalFileChanges = false;
484-
_repo.Remove(filePath, removeFromWorkingDirectory);
501+
//_repo.Remove(filePath, removeFromWorkingDirectory); // deprecated on LibGit2Sharp from v0.24.0
502+
LibGit2Sharp.Commands.Remove(_repo, filePath, removeFromWorkingDirectory);
485503
NotifyExternalFileChanges = true;
486504
}
487505
catch (LibGit2SharpException ex)
@@ -554,7 +572,8 @@ public override void DeleteBranch(string branchName)
554572
};
555573
}
556574

557-
_repo.Network.Push(branch.Remote, ":" + _repo.Branches[branchName].UpstreamBranchCanonicalName, options);
575+
//_repo.Network.Push(branch.Remote, ":" + _repo.Branches[branchName].UpstreamBranchCanonicalName, options); // deprecated on LibGit2Sharp from v0.24.0
576+
_repo.Network.Push(_repo.Network.Remotes[branchName], ":" + _repo.Branches[branchName].UpstreamBranchCanonicalName, options);
558577
}
559578

560579
// remote local repo

Rubberduck.SourceControl/Rubberduck.SourceControl.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
<LangVersion>7.1</LangVersion>
3939
</PropertyGroup>
4040
<ItemGroup>
41-
<Reference Include="LibGit2Sharp">
42-
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll</HintPath>
43-
<Private>True</Private>
41+
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
42+
<SpecificVersion>False</SpecificVersion>
43+
<HintPath>..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
4444
</Reference>
4545
<Reference Include="Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
4646
<SpecificVersion>False</SpecificVersion>
@@ -82,6 +82,7 @@
8282
</Compile>
8383
</ItemGroup>
8484
<ItemGroup>
85+
<None Include="_SourceControlClassDiagram.cd" />
8586
<None Include="packages.config" />
8687
</ItemGroup>
8788
<ItemGroup>

0 commit comments

Comments
 (0)