Skip to content
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

Add RevWalker #2038

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0a6c5bf
Add RevWalker
jairbubbles May 20, 2023
b7f53a0
feat: Add CustomHeaders to PushOptions
James-LG Nov 3, 2023
1201220
Update MinVer
bording Nov 4, 2023
30b2c1c
Update CHANGES.md for v0.28
bording Nov 4, 2023
c63e2f3
Update LibGit2Sharp.NativeBinaries to 2.0.321
bording Nov 27, 2023
de6efb9
Update GitFetchOptions to include new Depth value
bording Nov 27, 2023
8b90255
Remove CentOS 7 from test matrix
bording Nov 27, 2023
5bace98
Update test to match new sort order
bording Nov 27, 2023
edd862a
Update GitProxyOptions
bording Nov 25, 2023
24b242e
Add public proxy APIs
bording Nov 25, 2023
12975be
No reason to derive from FetchOptionsBase and have FetchOptions property
bording Nov 26, 2023
19b955e
Wire up proxy options
bording Nov 26, 2023
e717b4b
Ensure FetchOptions property is non-null
bording Nov 26, 2023
edd325b
Make ProxyOptions sealed to satisfy test
bording Nov 26, 2023
e80a980
Remove property setters since options are initialized
bording Nov 26, 2023
54c085a
Add XML comments
bording Nov 26, 2023
829d725
Update how submodule fetch options are handled
bording Nov 26, 2023
baf1e46
Update CHANGES.md for v0.29
bording Dec 3, 2023
1b3c823
Add project to test trimming compatibility
bording Mar 14, 2024
67a5d17
Address trimming warnings
bording Mar 14, 2024
ae8f912
Use .NET 8 SDK
bording Mar 14, 2024
7090e44
Fix failing test
bording Mar 16, 2024
142c995
Add net8.0 test targets
bording Mar 16, 2024
f4d3a47
Use .NET 8 SDK artifacts output
bording Mar 16, 2024
a5b5009
Update packages
bording Mar 16, 2024
20a3210
Fix test analyzer warnings
bording Mar 16, 2024
41732ac
Update workflow actions
bording Mar 16, 2024
d63ced1
Update testing matrix
bording Mar 16, 2024
32f647c
Fix analyzer warnings
bording Mar 16, 2024
cf318fb
Clean up more analyzer warnings
bording Mar 16, 2024
5d52455
Update LibGit2Sharp.NativeBinaries to 2.0.322
bording Mar 16, 2024
b75d5e1
Increase assert range to avoid flaky tests
bording Mar 17, 2024
b3743b7
Update CHANGES.md for v0.30
bording Mar 19, 2024
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
61 changes: 43 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,58 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3.5.0
uses: actions/checkout@v4.1.2
with:
fetch-depth: 0
- name: Install .NET SDK
uses: actions/setup-dotnet@v3.0.3
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
run: dotnet build LibGit2Sharp.sln --configuration Release
- name: Upload packages
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4.3.1
with:
name: NuGet packages
path: bin/Packages/
path: artifacts/package/
retention-days: 7
- name: Verify trimming compatibility
run: dotnet publish TrimmingTestApp
test:
name: Test / ${{ matrix.os }} / ${{ matrix.arch }} / ${{ matrix.tfm }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
arch: [ amd64 ]
os: [ windows-2019, macos-11 ]
tfm: [ net472, net6.0, net7.0 ]
arch: [ x64 ]
os: [ windows-2019, windows-2022, macos-11, macos-12, macos-13 ]
tfm: [ net472, net6.0, net8.0 ]
exclude:
- os: macos-11
tfm: net472
- os: macos-11
tfm: net8.0
- os: macos-12
tfm: net472
- os: macos-13
tfm: net472
include:
- arch: arm64
os: macos-14
tfm: net6.0
- arch: arm64
os: macos-14
tfm: net8.0
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3.5.0
uses: actions/checkout@v4.1.2
with:
fetch-depth: 0
- name: Install .NET SDK
uses: actions/setup-dotnet@v3.0.3
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: |
7.0.x
8.0.x
6.0.x
- name: Run ${{ matrix.tfm }} tests
run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING
Expand All @@ -62,22 +77,32 @@ jobs:
matrix:
arch: [ amd64 ]
# arch: [ amd64, arm64 ]
distro: [ alpine.3.13, alpine.3.14, alpine.3.15, alpine.3.16, alpine.3.17, centos.7, centos.stream.8, debian.10, debian.11, fedora.36, ubuntu.18.04, ubuntu.20.04, ubuntu.22.04 ]
sdk: [ '6.0', '7.0' ]
distro: [ alpine.3.13, alpine.3.14, alpine.3.15, alpine.3.16, alpine.3.17, alpine.3.18, centos.stream.8, debian.10, debian.11, fedora.36, fedora.37, ubuntu.18.04, ubuntu.20.04, ubuntu.22.04 ]
sdk: [ '6.0', '8.0' ]
exclude:
- distro: alpine.3.13
sdk: '7.0'
sdk: '8.0'
- distro: alpine.3.14
sdk: '7.0'
sdk: '8.0'
- distro: alpine.3.15
sdk: '8.0'
- distro: alpine.3.16
sdk: '8.0'
- distro: debian.10
sdk: '8.0'
- distro: fedora.36
sdk: '8.0'
- distro: ubuntu.18.04
sdk: '8.0'
include:
- sdk: '6.0'
tfm: net6.0
- sdk: '7.0'
tfm: net7.0
- sdk: '8.0'
tfm: net8.0
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3.5.0
uses: actions/checkout@v4.1.2
with:
fetch-depth: 0
- name: Setup QEMU
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ _ReSharper*/
*.DotSettings

_NCrunch_LibGit2Sharp/
packages/
artifacts/
worktree.playlist
22 changes: 22 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# LibGit2Sharp Changes

## v0.30 - ([diff](https://github.com/libgit2/libgit2sharp/compare/0.29.0..0.30.0))

### Changes
- This release includes [libgit2 v1.7.2](https://github.com/libgit2/libgit2/releases/tag/v1.7.2).
- Updates for trimming compatibility [#2084](https://github.com/libgit2/libgit2sharp/pull/2084)
- Updates for .NET 8 [#2085](https://github.com/libgit2/libgit2sharp/pull/2085)

## v0.29 - ([diff](https://github.com/libgit2/libgit2sharp/compare/0.28.0..0.29.0))

### Changes
- This release includes [libgit2 v1.7.1](https://github.com/libgit2/libgit2/releases/tag/v1.7.1).
- CI changes for the native binaries has removed support for CentOS 7. See [#2066](https://github.com/libgit2/libgit2sharp/pull/2066) for details.

### Additions
- Add proxy options [#2065](https://github.com/libgit2/libgit2sharp/pull/2065)
- See PR for details, including some breaking changes to `CloneOptions` and `SubmoduleUpdateOptions`

## v0.28 - ([diff](https://github.com/libgit2/libgit2sharp/compare/0.27.2..0.28.0))

### Additions
- Add CustomHeaders to PushOptions [#2052](https://github.com/libgit2/libgit2sharp/pull/2052)

## v0.27.2 - ([diff](https://github.com/libgit2/libgit2sharp/compare/0.27.1..0.27.2))

### Changes
Expand Down
5 changes: 2 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project>

<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputPath>$(MSBuildThisFileDirectory)bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\Packages\</PackageOutputPath>
<UseArtifactsOutput>true</UseArtifactsOutput>
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
</PropertyGroup>

Expand Down
5 changes: 2 additions & 3 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -103,7 +102,7 @@ public void CanCreateAnUnbornBranch()
public void CanCreateBranchUsingAbbreviatedSha()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);

Expand Down Expand Up @@ -1001,7 +1000,7 @@ public void OnlyOneBranchIsTheHead()
continue;
}

Assert.True(false, string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
Assert.Fail(string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
}

Assert.NotNull(head);
Expand Down
108 changes: 56 additions & 52 deletions LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ public void CallsProgressCallbacks(string url)

Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
{
OnTransferProgress = _ => { transferWasCalled = true; return true; },
OnProgress = progress => { progressWasCalled = true; return true; },
OnUpdateTips = (name, oldId, newId) => { updateTipsWasCalled = true; return true; },
FetchOptions =
{
OnTransferProgress = _ => { transferWasCalled = true; return true; },
OnProgress = progress => { progressWasCalled = true; return true; },
OnUpdateTips = (name, oldId, newId) => { updateTipsWasCalled = true; return true; }
},
OnCheckoutProgress = (a, b, c) => checkoutWasCalled = true

});

Assert.True(transferWasCalled);
Expand All @@ -174,7 +178,7 @@ public void CanCloneWithCredentials()
string clonedRepoPath = Repository.Clone(Constants.PrivateRepoUrl, scd.DirectoryPath,
new CloneOptions()
{
CredentialsProvider = Constants.PrivateRepoCredentials
FetchOptions = { CredentialsProvider = Constants.PrivateRepoCredentials }
});


Expand Down Expand Up @@ -249,43 +253,46 @@ public void CanInspectCertificateOnClone(string url, string hostname, Type certT

var options = new CloneOptions
{
CertificateCheck = (cert, valid, host) =>
FetchOptions =
{
wasCalled = true;

Assert.Equal(hostname, host);
Assert.Equal(certType, cert.GetType());

if (certType == typeof(CertificateX509))
CertificateCheck = (cert, valid, host) =>
{
Assert.True(valid);
var x509 = ((CertificateX509)cert).Certificate;
// we get a string with the different fields instead of a structure, so...
Assert.Contains("CN=github.com,", x509.Subject);
checksHappy = true;
return false;
}
wasCalled = true;

Assert.Equal(hostname, host);
Assert.Equal(certType, cert.GetType());

if (certType == typeof(CertificateX509))
{
Assert.True(valid);
var x509 = ((CertificateX509)cert).Certificate;
// we get a string with the different fields instead of a structure, so...
Assert.Contains("CN=github.com", x509.Subject);
checksHappy = true;
return false;
}

if (certType == typeof(CertificateSsh))
{
var hostkey = (CertificateSsh)cert;
Assert.True(hostkey.HasMD5);
/*
* Once you've connected and thus your ssh has stored the hostkey,
* you can get the hostkey for a host with
*
* ssh-keygen -F github.com -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':'
*
* though GitHub's hostkey won't change anytime soon.
*/
Assert.Equal("1627aca576282d36631b564debdfa648",
BitConverter.ToString(hostkey.HashMD5).ToLower().Replace("-", ""));
checksHappy = true;
return false;
}

if (certType == typeof(CertificateSsh))
{
var hostkey = (CertificateSsh)cert;
Assert.True(hostkey.HasMD5);
/*
* Once you've connected and thus your ssh has stored the hostkey,
* you can get the hostkey for a host with
*
* ssh-keygen -F github.com -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':'
*
* though GitHub's hostkey won't change anytime soon.
*/
Assert.Equal("1627aca576282d36631b564debdfa648",
BitConverter.ToString(hostkey.HashMD5).ToLower().Replace("-", ""));
checksHappy = true;
return false;
}

return false;
},
}
};

Assert.Throws<UserCancelledException>(() =>
Expand Down Expand Up @@ -432,9 +439,12 @@ public void CanRecursivelyCloneSubmodules()
{
RecurseSubmodules = true,
OnCheckoutProgress = checkoutProgressHandler,
OnUpdateTips = remoteRefUpdated,
RepositoryOperationStarting = repositoryOperationStarting,
RepositoryOperationCompleted = repositoryOperationCompleted,
FetchOptions =
{
OnUpdateTips = remoteRefUpdated,
RepositoryOperationStarting = repositoryOperationStarting,
RepositoryOperationCompleted = repositoryOperationCompleted
}
};

string clonedRepoPath = Repository.Clone(uri.AbsolutePath, scd.DirectoryPath, options);
Expand Down Expand Up @@ -517,7 +527,7 @@ public void CanCancelRecursiveClone()
CloneOptions options = new CloneOptions()
{
RecurseSubmodules = true,
RepositoryOperationStarting = repositoryOperationStarting,
FetchOptions = { RepositoryOperationStarting = repositoryOperationStarting }
};

Assert.Throws<UserCancelledException>(() =>
Expand Down Expand Up @@ -557,10 +567,8 @@ public void CannotCloneWithForbiddenCustomHeaders()
const string url = "https://github.com/libgit2/TestGitRepository";

const string knownHeader = "User-Agent: mygit-201";
var cloneOptions = new CloneOptions()
{
FetchOptions = new FetchOptions { CustomHeaders = new String[] { knownHeader } }
};
var cloneOptions = new CloneOptions();
cloneOptions.FetchOptions.CustomHeaders = new string[] { knownHeader };

Assert.Throws<LibGit2SharpException>(() => Repository.Clone(url, scd.DirectoryPath, cloneOptions));
}
Expand All @@ -573,10 +581,8 @@ public void CannotCloneWithMalformedCustomHeaders()
const string url = "https://github.com/libgit2/TestGitRepository";

const string knownHeader = "hello world";
var cloneOptions = new CloneOptions()
{
FetchOptions = new FetchOptions { CustomHeaders = new String[] { knownHeader } }
};
var cloneOptions = new CloneOptions();
cloneOptions.FetchOptions.CustomHeaders = new string[] { knownHeader };

Assert.Throws<LibGit2SharpException>(() => Repository.Clone(url, scd.DirectoryPath, cloneOptions));
}
Expand All @@ -589,10 +595,8 @@ public void CanCloneWithCustomHeaders()
const string url = "https://github.com/libgit2/TestGitRepository";

const string knownHeader = "X-Hello: world";
var cloneOptions = new CloneOptions()
{
FetchOptions = new FetchOptions { CustomHeaders = new String[] { knownHeader } }
};
var cloneOptions = new CloneOptions();
cloneOptions.FetchOptions.CustomHeaders = new string[] { knownHeader };

var clonedRepoPath = Repository.Clone(url, scd.DirectoryPath, cloneOptions);
Assert.True(Directory.Exists(clonedRepoPath));
Expand Down
Loading