Skip to content

Commit 8988bef

Browse files
author
A-Ovchinnikov-mx
authored
Update libgit2 to v1.2.0 (#16)
1 parent 2e22653 commit 8988bef

13 files changed

+40
-25
lines changed

.github/workflows/Build_and_publish_package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# After build we copy the binaries to package output folder
3636
# Finally we pack and push the package to github packages
3737
- name: Deploy Package
38-
if: github.event_name == 'push'
38+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
3939
run: |
4040
dotnet nuget add source "https://nuget.pkg.github.com/mendix/index.json" --name "GitHub" --username ${{ secrets.GHPACKAGESUSER }} --password ${{ secrets.GHPACKAGESTOKEN }}
4141
dotnet nuget push "**/mx_nuget/Mendix.LibGit2Sharp*.nupkg" --source "GitHub" --skip-duplicate

LibGit2Sharp.Tests/BlobFixture.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Text;
44
using LibGit2Sharp.Tests.TestHelpers;
55
using Xunit;
6-
using Xunit.Extensions;
76

87
namespace LibGit2Sharp.Tests
98
{
@@ -44,6 +43,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText)
4443
}
4544
}
4645

46+
#if NETFRAMEWORK || NETCOREAPP2_1
4747
[Theory]
4848
[InlineData("ascii", 4, "31 32 33 34")]
4949
[InlineData("utf-7", 4, "31 32 33 34")]
@@ -83,6 +83,7 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect
8383
Assert.Equal(expectedUtf7Chars, string.Join(" ", utf7Chars));
8484
}
8585
}
86+
#endif
8687

8788
[Fact]
8889
public void CanGetBlobSize()
@@ -185,7 +186,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
185186
var sb = new StringBuilder();
186187
for (int j = 0; j < 2000; j++)
187188
{
188-
sb.Append(((i + 1)*(j + 1)).ToString("X8"));
189+
sb.Append(((i + 1) * (j + 1)).ToString("X8"));
189190
}
190191
File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "small.txt"), sb.ToString());
191192
}

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private void AssertLocalClone(string url, string path = null, bool isCloningAnEm
7070
Assert.NotEqual(originalRepo.Info.Path, clonedRepo.Info.Path);
7171
Assert.Equal(originalRepo.Head, clonedRepo.Head);
7272

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

7676
Assert.Equal(originalRepo.Tags.Count(), clonedRepo.Tags.Count());

LibGit2Sharp.Tests/FetchFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public void FetchHonorsTheFetchPruneConfigurationEntry()
215215

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

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

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

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

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;net5.0</TargetFrameworks>
4+
<TargetFrameworks>net472;netcoreapp2.1;net5.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
9-
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' != 'net5.0'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
10-
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' != 'net5.0'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
9+
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
10+
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
15-
<PackageReference Include="Moq" Version="4.10.1" />
16-
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
14+
<PackageReference Include="coverlet.msbuild" Version="2.7.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
16+
<PackageReference Include="Moq" Version="4.16.1" />
1717
<PackageReference Include="xunit" Version="2.4.1" />
1818
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
20-
<PackageReference Include="xunit.skippablefact" Version="1.3.12" />
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
20+
<PackageReference Include="xunit.skippablefact" Version="1.4.13" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
2424
<Compile Include="..\LibGit2Sharp\Core\Platform.cs" Link="TestHelpers\Platform.cs" />
25-
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' == 'net5.0'" />
25+
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' != 'net472'" />
2626
<Content Include="Resources\**\*.*" CopyToOutputDirectory="PreserveNewest" />
2727
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
2828
</ItemGroup>

LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Reflection;
88
using System.Text;
99
using System.Text.RegularExpressions;
10-
using LibGit2Sharp.Core;
1110
using Xunit;
1211

1312
namespace LibGit2Sharp.Tests.TestHelpers
@@ -21,7 +20,7 @@ public BaseFixture()
2120
BuildFakeConfigs(this);
2221

2322
#if LEAKS_IDENTIFYING
24-
LeaksContainer.Clear();
23+
Core.LeaksContainer.Clear();
2524
#endif
2625
}
2726

@@ -65,7 +64,11 @@ private static void SetUpTestEnvironment()
6564

6665
if (resourcesPath == null)
6766
{
67+
#if NETFRAMEWORK
6868
resourcesPath = Path.Combine(Directory.GetParent(new Uri(typeof(BaseFixture).GetTypeInfo().Assembly.CodeBase).LocalPath).FullName, "Resources");
69+
#else
70+
resourcesPath = Path.Combine(Directory.GetParent(typeof(BaseFixture).GetTypeInfo().Assembly.Location).FullName, "Resources");
71+
#endif
6972
}
7073

7174
ResourcesDirectory = new DirectoryInfo(resourcesPath);
@@ -273,11 +276,11 @@ public virtual void Dispose()
273276
GC.Collect();
274277
GC.WaitForPendingFinalizers();
275278

276-
if (LeaksContainer.TypeNames.Any())
279+
if (Core.LeaksContainer.TypeNames.Any())
277280
{
278281
Assert.False(true, string.Format("Some handles of the following types haven't been properly released: {0}.{1}"
279282
+ "In order to get some help fixing those leaks, uncomment the define LEAKS_TRACKING in Libgit2Object.cs{1}"
280-
+ "and run the tests locally.", string.Join(", ", LeaksContainer.TypeNames), Environment.NewLine));
283+
+ "and run the tests locally.", string.Join(", ", Core.LeaksContainer.TypeNames), Environment.NewLine));
281284
}
282285
#endif
283286
}

LibGit2Sharp/Core/GitOdbBackend.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ static GitOdbBackend()
3333
public exists_prefix_callback ExistsPrefix;
3434
public IntPtr Refresh;
3535
public foreach_callback Foreach;
36+
37+
private IntPtr Padding; // TODO: add writemidx
38+
3639
public IntPtr Writepack;
3740
public IntPtr Freshen;
3841
public free_callback Free;

LibGit2Sharp/Core/GitRebaseOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ internal class GitRebaseOptions
1818

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

21+
private IntPtr padding; // TODO: add git_commit_create_cb
22+
2123
public NativeMethods.commit_signing_callback signing_callback;
2224
}
2325
}

LibGit2Sharp/Core/GitRemoteCallbacks.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ internal struct GitRemoteCallbacks
3333

3434
internal IntPtr transport;
3535

36+
private IntPtr padding; // TODO: add git_remote_ready_cb
37+
3638
internal IntPtr payload;
3739

3840
internal NativeMethods.url_resolve_callback resolve_url;

LibGit2Sharp/Core/GitStatusOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ internal class GitStatusOptions : IDisposable
1313

1414
public GitStrArrayManaged PathSpec;
1515

16+
public IntPtr Baseline = IntPtr.Zero;
17+
1618
public void Dispose()
1719
{
1820
PathSpec.Dispose();

LibGit2Sharp/Core/GitWorktree.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ internal enum GitWorktreePruneOptionFlags : uint
3333
internal class git_worktree_add_options
3434
{
3535
public uint version = 1;
36-
36+
3737
public int locked;
38+
39+
public IntPtr @ref = IntPtr.Zero;
3840
}
3941

4042
[StructLayout(LayoutKind.Sequential)]

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="Mendix.LibGit2Sharp.NativeBinaries" Version="[1.111.0]" PrivateAssets="none" />
37+
<PackageReference Include="Mendix.LibGit2Sharp.NativeBinaries" Version="[1.120.0]" PrivateAssets="none" />
3838
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
39-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.205" PrivateAssets="all" />
39+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.220" PrivateAssets="all" />
4040
</ItemGroup>
4141

4242
<Import Project="..\Targets\CodeGenerator.targets" />

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.111.100",
3+
"version": "1.120.0",
44
"cloudBuild": {
55
"buildNumber": {
66
"enabled": true

0 commit comments

Comments
 (0)