From 34772bb1a62fb462baa455758078c8771d6e235d Mon Sep 17 00:00:00 2001 From: Stephen Brown Date: Sun, 5 Feb 2023 13:01:46 +0100 Subject: [PATCH 1/2] Add support for git push with custom headers --- LibGit2Sharp/Network.cs | 1 + LibGit2Sharp/PushOptions.cs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/LibGit2Sharp/Network.cs b/LibGit2Sharp/Network.cs index d5f032058..b53210b1e 100644 --- a/LibGit2Sharp/Network.cs +++ b/LibGit2Sharp/Network.cs @@ -376,6 +376,7 @@ public virtual void Push(Remote remote, IEnumerable pushRefSpecs, PushOp PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism, RemoteCallbacks = gitCallbacks, ProxyOptions = new GitProxyOptions { Version = 1 }, + CustomHeaders = pushOptions.CustomHeaders?.Length > 0 ? GitStrArrayManaged.BuildFrom(pushOptions.CustomHeaders) : new GitStrArrayManaged() }); } } diff --git a/LibGit2Sharp/PushOptions.cs b/LibGit2Sharp/PushOptions.cs index 99c65dd8b..ebef520ac 100644 --- a/LibGit2Sharp/PushOptions.cs +++ b/LibGit2Sharp/PushOptions.cs @@ -27,6 +27,27 @@ public sealed class PushOptions /// public int PackbuilderDegreeOfParallelism { get; set; } + /// + /// Get/Set the custom headers. + /// + /// + /// This allows you to set custom headers (e.g. X-Forwarded-For, + /// X-Request-Id, etc), + /// + /// + /// + /// Libgit2 sets some headers for HTTP requests (User-Agent, Host, + /// Accept, Content-Type, Transfer-Encoding, Content-Length, Accept) that + /// cannot be overriden. + /// + /// + /// var fetchOptions - new FetchOptions() { + /// CustomHeaders = new String[] {"X-Request-Id: 12345"} + /// }; + /// + /// The custom headers string array + public string[] CustomHeaders { get; set; } + /// /// Delegate to report errors when updating references on the remote. /// From ac69d7d2fbd6947145167d4ec56e15f8649c71f1 Mon Sep 17 00:00:00 2001 From: Stephen Brown Date: Tue, 17 Oct 2023 15:46:11 +0200 Subject: [PATCH 2/2] Try to build --- .github/workflows/ci.yml | 61 +------------------------------- LibGit2Sharp/LibGit2Sharp.csproj | 7 ++-- 2 files changed, 5 insertions(+), 63 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f44285812..21b9f1b8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,63 +29,4 @@ jobs: with: name: NuGet packages path: bin/Packages/ - retention-days: 7 - 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 ] - exclude: - - os: macos-11 - tfm: net472 - fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v3.5.0 - with: - fetch-depth: 0 - - name: Install .NET SDK - uses: actions/setup-dotnet@v3.0.3 - with: - dotnet-version: | - 7.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 - test-linux: - name: Test / ${{ matrix.distro }} / ${{ matrix.arch }} / ${{ matrix.tfm }} - runs-on: ubuntu-22.04 - strategy: - 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' ] - exclude: - - distro: alpine.3.13 - sdk: '7.0' - - distro: alpine.3.14 - sdk: '7.0' - include: - - sdk: '6.0' - tfm: net6.0 - - sdk: '7.0' - tfm: net7.0 - fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v3.5.0 - with: - fetch-depth: 0 - - name: Setup QEMU - if: matrix.arch == 'arm64' - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - - name: Run ${{ matrix.tfm }} tests - run: | - git_command="git config --global --add safe.directory /app" - test_command="dotnet test LibGit2Sharp.sln --configuration Release -p:TargetFrameworks=${{ matrix.tfm }} --logger "GitHubActions" -p:ExtraDefine=LEAKS_IDENTIFYING" - docker run -t --rm --platform linux/${{ matrix.arch }} -v "$PWD:/app" gittools/build-images:${{ matrix.distro }}-sdk-${{ matrix.sdk }} sh -c "$git_command && $test_command" - + retention-days: 7 \ No newline at end of file diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index f690c9107..518f6ff34 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -3,13 +3,14 @@ net472;net6.0 true - LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET + LibGit2Sharp-evolvedlight brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET LibGit2Sharp contributors Copyright © LibGit2Sharp contributors libgit2 git - https://github.com/libgit2/libgit2sharp/ + https://github.com/evolvedlight/libgit2sharp/ LibGit2Sharp contributors true + LibGit2Sharp-evolvedlight true embedded true @@ -43,7 +44,7 @@ - https://github.com/libgit2/libgit2sharp/blob/$(SourceRevisionId)/CHANGES.md + https://github.com/evolvedlight/libgit2sharp/blob/$(SourceRevisionId)/CHANGES.md