Skip to content

Commit

Permalink
Updated LibGit2Sharp to version v0.24.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Nelson Vides committed Nov 20, 2017
1 parent bed752c commit d7fc5ef
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 23 deletions.
9 changes: 6 additions & 3 deletions RetailCoder.VBE/Rubberduck.csproj
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" />
<Import Project="..\packages\Antlr4.4.3.0\build\Antlr4.props" Condition="Exists('..\packages\Antlr4.4.3.0\build\Antlr4.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand All @@ -12,7 +13,8 @@
<AssemblyName>Rubberduck</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>480c0557</NuGetPackageImportStamp>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
Expand Down Expand Up @@ -256,9 +258,9 @@
<Reference Include="Infralution.Localization.Wpf">
<HintPath>..\libs\Infralution.Localization.Wpf.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll</HintPath>
<HintPath>..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
Expand Down Expand Up @@ -1485,6 +1487,7 @@
<Error Condition="!Exists('..\packages\Antlr4.4.3.0\build\Antlr4.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Antlr4.4.3.0\build\Antlr4.props'))" />
<Error Condition="!Exists('..\packages\Antlr4.4.3.0\build\Antlr4.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Antlr4.4.3.0\build\Antlr4.targets'))" />
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<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'))" />
</Target>
<Import Project="..\packages\Antlr4.4.3.0\build\Antlr4.targets" Condition="Exists('..\packages\Antlr4.4.3.0\build\Antlr4.targets')" />
<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions RetailCoder.VBE/packages.config
Expand Up @@ -7,6 +7,8 @@
<package id="Castle.Windsor" version="4.0.0" targetFramework="net45" />
<package id="EasyHook" version="2.7.6270" targetFramework="net45" />
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net45" />
<package id="LibGit2Sharp" version="0.24.0" targetFramework="net45" />
<package id="LibGit2Sharp.NativeBinaries" version="1.0.185" targetFramework="net45" />
<package id="NLog" version="4.0.1" targetFramework="net45" />
<package id="NLog.Schema" version="4.0.1" targetFramework="net45" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />
Expand Down
47 changes: 33 additions & 14 deletions Rubberduck.SourceControl/GitProvider.cs
Expand Up @@ -185,15 +185,16 @@ public override IRepository InitVBAProject(string directory)
var status = repo.RetrieveStatus(new StatusOptions {DetectRenamesInWorkDir = true});
foreach (var stat in status.Untracked)
{
repo.Stage(stat.FilePath);
// repo.Stage(stat.FilePath); //deprecated from LibGit2Sharp v0.24
LibGit2Sharp.Commands.Stage(repo, stat.FilePath);
}

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

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

RequeryUnsyncedCommits();
Expand All @@ -270,7 +279,8 @@ public override void Pull()
};

var signature = GetSignature();
_repo.Network.Pull(signature, options);
//_repo.Network.Pull(signature, options); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Pull(_repo, signature, options);

base.Pull();

Expand All @@ -289,7 +299,7 @@ public override void Commit(string message)
//The default behavior of LibGit2Sharp.Repo.Commit is to throw an exception if no signature is found,
// but BuildSignature() does not throw if a signature is not found, it returns "unknown" instead.
// so we pass a signature that won't throw along to the commit.
_repo.Commit(message, GetSignature());
_repo.Commit(message, GetSignature(), GetSignature());
}
catch (LibGit2SharpException ex)
{
Expand All @@ -301,7 +311,8 @@ public override void Stage(string filePath)
{
try
{
_repo.Stage(filePath);
// _repo.Stage(filePath); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Stage(_repo, filePath);
}
catch (LibGit2SharpException ex)
{
Expand All @@ -313,7 +324,8 @@ public override void Stage(IEnumerable<string> filePaths)
{
try
{
_repo.Stage(filePaths);
//_repo.Stage(filePaths); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Stage(_repo, filePaths);
}
catch (LibGit2SharpException ex)
{
Expand Down Expand Up @@ -348,7 +360,8 @@ public override void Checkout(string branch)
{
try
{
_repo.Checkout(_repo.Branches[branch]);
//_repo.Checkout(_repo.Branches[branch]); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Checkout(_repo, branch);
base.Checkout(branch);

RequeryUnsyncedCommits();
Expand All @@ -364,7 +377,8 @@ public override void CreateBranch(string branch)
try
{
_repo.CreateBranch(branch);
_repo.Checkout(branch);
//_repo.Checkout(branch); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Checkout(_repo,branch);

RequeryUnsyncedCommits();
}
Expand All @@ -379,7 +393,8 @@ public override void CreateBranch(string sourceBranch, string branch)
try
{
_repo.CreateBranch(branch, _repo.Branches[sourceBranch].Commits.Last());
_repo.Checkout(branch);
//_repo.Checkout(branch); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Checkout(_repo, branch);

RequeryUnsyncedCommits();
}
Expand Down Expand Up @@ -417,7 +432,8 @@ public override void Unpublish(string branch)
{
try
{
var remote = _repo.Branches[branch].Remote;
//var remote = _repo.Branches[branch].Remote; // deprecated on LibGit2Sharp from v0.24.0
var remote = _repo.Network.Remotes[branch];

_repo.Branches.Update(_repo.Branches[branch], b => b.Remote = remote.Name,
b => b.TrackedBranch = null, b => b.UpstreamBranch = null);
Expand Down Expand Up @@ -463,7 +479,8 @@ public override void AddFile(string filePath)
try
{
// https://github.com/libgit2/libgit2sharp/wiki/Git-add
_repo.Stage(filePath);
//_repo.Stage(filePath); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Stage(_repo, filePath);
}
catch (LibGit2SharpException ex)
{
Expand All @@ -481,7 +498,8 @@ public override void RemoveFile(string filePath, bool removeFromWorkingDirectory
try
{
NotifyExternalFileChanges = false;
_repo.Remove(filePath, removeFromWorkingDirectory);
//_repo.Remove(filePath, removeFromWorkingDirectory); // deprecated on LibGit2Sharp from v0.24.0
LibGit2Sharp.Commands.Remove(_repo, filePath, removeFromWorkingDirectory);
NotifyExternalFileChanges = true;
}
catch (LibGit2SharpException ex)
Expand Down Expand Up @@ -554,7 +572,8 @@ public override void DeleteBranch(string branchName)
};
}

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

// remote local repo
Expand Down
7 changes: 4 additions & 3 deletions Rubberduck.SourceControl/Rubberduck.SourceControl.csproj
Expand Up @@ -38,9 +38,9 @@
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="LibGit2Sharp">
<HintPath>..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll</HintPath>
<Private>True</Private>
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -82,6 +82,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="_SourceControlClassDiagram.cd" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit d7fc5ef

Please sign in to comment.