Skip to content

Update libgit2 to v1.2.0 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
8 commits merged into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Build_and_publish_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# After build we copy the binaries to package output folder
# Finally we pack and push the package to github packages
- name: Deploy Package
if: github.event_name == 'push'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
dotnet nuget add source "https://nuget.pkg.github.com/mendix/index.json" --name "GitHub" --username ${{ secrets.GHPACKAGESUSER }} --password ${{ secrets.GHPACKAGESTOKEN }}
dotnet nuget push "**/mx_nuget/Mendix.LibGit2Sharp*.nupkg" --source "GitHub" --skip-duplicate
Expand Down
5 changes: 3 additions & 2 deletions LibGit2Sharp.Tests/BlobFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -44,6 +43,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText)
}
}

#if NETFRAMEWORK || NETCOREAPP2_1
[Theory]
[InlineData("ascii", 4, "31 32 33 34")]
[InlineData("utf-7", 4, "31 32 33 34")]
Expand Down Expand Up @@ -83,6 +83,7 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect
Assert.Equal(expectedUtf7Chars, string.Join(" ", utf7Chars));
}
}
#endif

[Fact]
public void CanGetBlobSize()
Expand Down Expand Up @@ -185,7 +186,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
var sb = new StringBuilder();
for (int j = 0; j < 2000; j++)
{
sb.Append(((i + 1)*(j + 1)).ToString("X8"));
sb.Append(((i + 1) * (j + 1)).ToString("X8"));
}
File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "small.txt"), sb.ToString());
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void AssertLocalClone(string url, string path = null, bool isCloningAnEm
Assert.NotEqual(originalRepo.Info.Path, clonedRepo.Info.Path);
Assert.Equal(originalRepo.Head, clonedRepo.Head);

Assert.Equal(originalRepo.Branches.Count(), clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(originalRepo.Branches.Count(), clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));
Assert.Equal(isCloningAnEmptyRepository ? 0 : 1, clonedRepo.Branches.Count(b => !b.IsRemote));

Assert.Equal(originalRepo.Tags.Count(), clonedRepo.Tags.Count());
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/FetchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void FetchHonorsTheFetchPruneConfigurationEntry()

using (var clonedRepo = new Repository(clonedRepoPath))
{
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));

// Drop one of the branches in the remote repository
using (var sourceRepo = new Repository(source))
Expand All @@ -226,17 +226,17 @@ public void FetchHonorsTheFetchPruneConfigurationEntry()
// No pruning when the configuration entry isn't defined
Assert.Null(clonedRepo.Config.Get<bool>("fetch.prune"));
Commands.Fetch(clonedRepo, "origin", new string[0], null, null, null);
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));

// No pruning when the configuration entry is set to false
clonedRepo.Config.Set<bool>("fetch.prune", false);
Commands.Fetch(clonedRepo, "origin", new string[0], null, null, null);
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));

// Auto pruning when the configuration entry is set to true
clonedRepo.Config.Set<bool>("fetch.prune", true);
Commands.Fetch(clonedRepo, "origin", new string[0], null, null, null);
Assert.Equal(4, clonedRepo.Branches.Count(b => b.IsRemote));
Assert.Equal(4, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));
}
}

Expand Down
18 changes: 9 additions & 9 deletions LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net5.0</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp2.1;net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' != 'net5.0'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' != 'net5.0'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="coverlet.msbuild" Version="2.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="xunit.skippablefact" Version="1.3.12" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="xunit.skippablefact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\LibGit2Sharp\Core\Platform.cs" Link="TestHelpers\Platform.cs" />
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' == 'net5.0'" />
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' != 'net472'" />
<Content Include="Resources\**\*.*" CopyToOutputDirectory="PreserveNewest" />
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using LibGit2Sharp.Core;
using Xunit;

namespace LibGit2Sharp.Tests.TestHelpers
Expand All @@ -21,7 +20,7 @@ public BaseFixture()
BuildFakeConfigs(this);

#if LEAKS_IDENTIFYING
LeaksContainer.Clear();
Core.LeaksContainer.Clear();
#endif
}

Expand Down Expand Up @@ -65,7 +64,11 @@ private static void SetUpTestEnvironment()

if (resourcesPath == null)
{
#if NETFRAMEWORK
resourcesPath = Path.Combine(Directory.GetParent(new Uri(typeof(BaseFixture).GetTypeInfo().Assembly.CodeBase).LocalPath).FullName, "Resources");
#else
resourcesPath = Path.Combine(Directory.GetParent(typeof(BaseFixture).GetTypeInfo().Assembly.Location).FullName, "Resources");
#endif
}

ResourcesDirectory = new DirectoryInfo(resourcesPath);
Expand Down Expand Up @@ -273,11 +276,11 @@ public virtual void Dispose()
GC.Collect();
GC.WaitForPendingFinalizers();

if (LeaksContainer.TypeNames.Any())
if (Core.LeaksContainer.TypeNames.Any())
{
Assert.False(true, string.Format("Some handles of the following types haven't been properly released: {0}.{1}"
+ "In order to get some help fixing those leaks, uncomment the define LEAKS_TRACKING in Libgit2Object.cs{1}"
+ "and run the tests locally.", string.Join(", ", LeaksContainer.TypeNames), Environment.NewLine));
+ "and run the tests locally.", string.Join(", ", Core.LeaksContainer.TypeNames), Environment.NewLine));
}
#endif
}
Expand Down
3 changes: 3 additions & 0 deletions LibGit2Sharp/Core/GitOdbBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ static GitOdbBackend()
public exists_prefix_callback ExistsPrefix;
public IntPtr Refresh;
public foreach_callback Foreach;

private IntPtr Padding; // TODO: add writemidx

public IntPtr Writepack;
public IntPtr Freshen;
public free_callback Free;
Expand Down
2 changes: 2 additions & 0 deletions LibGit2Sharp/Core/GitRebaseOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal class GitRebaseOptions

public GitCheckoutOpts checkout_options = new GitCheckoutOpts { version = 1 };

private IntPtr padding; // TODO: add git_commit_create_cb

public NativeMethods.commit_signing_callback signing_callback;
}
}
2 changes: 2 additions & 0 deletions LibGit2Sharp/Core/GitRemoteCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ internal struct GitRemoteCallbacks

internal IntPtr transport;

private IntPtr padding; // TODO: add git_remote_ready_cb

internal IntPtr payload;

internal NativeMethods.url_resolve_callback resolve_url;
Expand Down
2 changes: 2 additions & 0 deletions LibGit2Sharp/Core/GitStatusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ internal class GitStatusOptions : IDisposable

public GitStrArrayManaged PathSpec;

public IntPtr Baseline = IntPtr.Zero;

public void Dispose()
{
PathSpec.Dispose();
Expand Down
4 changes: 3 additions & 1 deletion LibGit2Sharp/Core/GitWorktree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ internal enum GitWorktreePruneOptionFlags : uint
internal class git_worktree_add_options
{
public uint version = 1;

public int locked;

public IntPtr @ref = IntPtr.Zero;
}

[StructLayout(LayoutKind.Sequential)]
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Mendix.LibGit2Sharp.NativeBinaries" Version="[1.111.0]" PrivateAssets="none" />
<PackageReference Include="Mendix.LibGit2Sharp.NativeBinaries" Version="[1.120.0]" PrivateAssets="none" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.205" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.220" PrivateAssets="all" />
</ItemGroup>

<Import Project="..\Targets\CodeGenerator.targets" />
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.111.100",
"version": "1.120.0",
"cloudBuild": {
"buildNumber": {
"enabled": true
Expand Down