diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 118649aa2..cf961279d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,20 +12,20 @@ env: jobs: build: name: Build - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3.5.0 with: fetch-depth: 0 - name: Install .NET SDK - uses: actions/setup-dotnet@v1.8.1 + uses: actions/setup-dotnet@v3.0.3 with: - dotnet-version: 6.0.x + dotnet-version: 7.0.x - name: Build run: dotnet build LibGit2Sharp.sln --configuration Release - name: Upload packages - uses: actions/upload-artifact@v2.2.4 + uses: actions/upload-artifact@v3.1.2 with: name: NuGet packages path: bin/Packages/ @@ -36,57 +36,48 @@ jobs: strategy: matrix: arch: [ amd64 ] - os: [windows-2019, macos-10.15] - tfm: [ net472, netcoreapp3.1, net6.0 ] + os: [ windows-2019, macos-11 ] + tfm: [ net472, net6.0, net7.0 ] exclude: - - os: macos-10.15 + - os: macos-11 tfm: net472 fail-fast: false steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3.5.0 with: fetch-depth: 0 - name: Install .NET SDK - uses: actions/setup-dotnet@v1.8.1 + uses: actions/setup-dotnet@v3.0.3 with: - dotnet-version: 6.0.x - - name: Install .NET Core 3.1 runtime - if: matrix.tfm == 'netcoreapp3.1' - uses: actions/setup-dotnet@v1.8.1 - with: - dotnet-version: 3.1.x + 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-20.04 + runs-on: ubuntu-22.04 strategy: matrix: arch: [ amd64 ] # arch: [ amd64, arm64 ] - distro: [ alpine.3.12, alpine.3.13, alpine.3.14, centos.7, centos.8, debian.9, debian.10, debian.11, fedora.33, ubuntu.18.04, ubuntu.20.04 ] - sdk: [ '6.0', '3.1' ] + 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: - - arch: arm64 - distro: alpine.3.12 - - arch: arm64 - distro: alpine.3.13 - sdk: '3.1' - - arch: arm64 - distro: alpine.3.14 - sdk: '3.1' - - arch: arm64 - distro: centos.7 + - distro: alpine.3.13 + sdk: '7.0' + - distro: alpine.3.14 + sdk: '7.0' include: - sdk: '6.0' tfm: net6.0 - - sdk: '3.1' - tfm: netcoreapp3.1 + - sdk: '7.0' + tfm: net7.0 fail-fast: false steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3.5.0 with: fetch-depth: 0 - name: Setup QEMU diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs index ea35e59ef..314dea379 100644 --- a/LibGit2Sharp.Tests/BlobFixture.cs +++ b/LibGit2Sharp.Tests/BlobFixture.cs @@ -45,7 +45,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText) } } -#if NETFRAMEWORK || NETCOREAPP3_1 //UTF-7 is disabled in .NET 5+ +#if NETFRAMEWORK //UTF-7 is disabled in .NET 5+ [Theory] [InlineData("ascii", 4, "31 32 33 34")] [InlineData("utf-7", 4, "31 32 33 34")] @@ -239,11 +239,11 @@ public void CanTellIfABlobIsMissing() // Manually delete the objects directory to simulate a partial clone Directory.Delete(Path.Combine(repoPath, "objects", "a8"), true); - using (var repo = new Repository(repoPath)) + using (var repo = new Repository(repoPath)) { // Look up for the tree that reference the blob which is now missing var tree = repo.Lookup("fd093bff70906175335656e6ce6ae05783708765"); - var blob = (Blob) tree["README"].Target; + var blob = (Blob)tree["README"].Target; Assert.Equal("a8233120f6ad708f843d861ce2b7228ec4e3dec6", blob.Sha); Assert.NotNull(blob); diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index 25e652522..c5cbb5f24 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 @@ -11,12 +11,12 @@ - - - - - - + + + + + + diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index f5d45f3cf..e20d755ba 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -66,7 +66,7 @@ private static string GetGlobalSettingsNativeLibraryPath() return Path.Combine(nativeLibraryDir, libgit2 + Platform.GetNativeLibraryExtension()); } -#if NETSTANDARD +#if NETFRAMEWORK private static bool TryUseNativeLibrary() => false; #else private static bool TryUseNativeLibrary() diff --git a/LibGit2Sharp/GlobalSettings.cs b/LibGit2Sharp/GlobalSettings.cs index f8db7401a..31cba0965 100644 --- a/LibGit2Sharp/GlobalSettings.cs +++ b/LibGit2Sharp/GlobalSettings.cs @@ -20,7 +20,7 @@ public static class GlobalSettings private static string nativeLibraryPath; private static bool nativeLibraryPathLocked; - private static string nativeLibraryDefaultPath; + private static readonly string nativeLibraryDefaultPath = null; static GlobalSettings() { @@ -29,19 +29,18 @@ static GlobalSettings() nativeLibraryPathAllowed = netFX || netCore; +#if NETFRAMEWORK if (netFX) { // For .NET Framework apps the dependencies are deployed to lib/win32/{architecture} directory nativeLibraryDefaultPath = Path.Combine(GetExecutingAssemblyDirectory(), "lib", "win32", Platform.ProcessorArchitecture); } - else - { - nativeLibraryDefaultPath = null; - } +#endif registeredFilters = new Dictionary(); } +#if NETFRAMEWORK private static string GetExecutingAssemblyDirectory() { // Assembly.CodeBase is not actually a correctly formatted @@ -66,6 +65,7 @@ private static string GetExecutingAssemblyDirectory() managedPath = Path.GetDirectoryName(managedPath); return managedPath; } +#endif /// /// Returns information related to the current LibGit2Sharp diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index c81dd7093..0b88a3af5 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netcoreapp3.1 + net472;net6.0 true LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET LibGit2Sharp contributors @@ -31,7 +31,7 @@ - + diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 52aceb321..b48c72a99 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -315,10 +315,10 @@ private unsafe Blob CreateBlob(Stream stream, string hintpath, long? numberOfByt throw new EndOfStreamException("The stream ended unexpectedly"); } } - catch(Exception e) + catch (Exception) { writestream.free(writestream_ptr); - throw e; + throw; } ObjectId id = Proxy.git_blob_create_fromstream_commit(writestream_ptr);