From 30caea39345cb36727aa0ed44bfe323cd438b27c Mon Sep 17 00:00:00 2001 From: nmeum Date: Mon, 30 Nov 2020 01:33:37 +0100 Subject: [PATCH] Relax libgit2 minor version check (#696) (#697) The major version must still be an exact match since libgit2 uses semantic versioning and changes to the major number indicate backwards incompatible changes to the API. Fixes: #695 (cherry picked from commit 1fabe95fb7275df980ff6ab03fb85eac91c5849d) --- .github/workflows/ci.yml | 6 ++++-- git_bundled_static.go | 4 ++-- git_system_dynamic.go | 4 ++-- git_system_static.go | 4 ++-- script/build-libgit2.sh | 5 +++++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caa52a4..b9b3ab0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,8 @@ jobs: build-system-dynamic: strategy: fail-fast: false + matrix: + libgit2: [ '1.0.0', '1.1.0' ] name: Go (system-wide, dynamic) runs-on: ubuntu-20.04 @@ -103,10 +105,10 @@ jobs: id: go - name: Check out code into the Go module directory uses: actions/checkout@v1 - - name: Build libgit2 + - name: Build libgit2 ${{ matrix.libgit2 }} run: | git submodule update --init - sudo ./script/build-libgit2.sh --dynamic --system + sudo env BUILD_LIBGIT_REF=v${{ matrix.libgit2 }} ./script/build-libgit2.sh --dynamic --system - name: Test run: make test diff --git a/git_bundled_static.go b/git_bundled_static.go index a5a590b..8076dbe 100644 --- a/git_bundled_static.go +++ b/git_bundled_static.go @@ -9,8 +9,8 @@ package git #cgo CFLAGS: -DLIBGIT2_STATIC #include -#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 0 -# error "Invalid libgit2 version; this git2go supports libgit2 v1.0" +#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 0 || LIBGIT2_VER_MINOR > 1 +# error "Invalid libgit2 version; this git2go supports libgit2 between v1.0.0 and v1.1.0". #endif */ import "C" diff --git a/git_system_dynamic.go b/git_system_dynamic.go index daed8ff..495fbf5 100644 --- a/git_system_dynamic.go +++ b/git_system_dynamic.go @@ -7,8 +7,8 @@ package git #cgo CFLAGS: -DLIBGIT2_DYNAMIC #include -#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 0 -# error "Invalid libgit2 version; this git2go supports libgit2 v1.0" +#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 0 || LIBGIT2_VER_MINOR > 1 +# error "Invalid libgit2 version; this git2go supports libgit2 between v1.0.0 and v1.1.0". #endif */ import "C" diff --git a/git_system_static.go b/git_system_static.go index d30676a..b016689 100644 --- a/git_system_static.go +++ b/git_system_static.go @@ -7,8 +7,8 @@ package git #cgo CFLAGS: -DLIBGIT2_STATIC #include -#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 0 -# error "Invalid libgit2 version; this git2go supports libgit2 v1.0" +#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 0 || LIBGIT2_VER_MINOR > 1 +# error "Invalid libgit2 version; this git2go supports libgit2 between v1.0.0 and v1.1.0". #endif */ import "C" diff --git a/script/build-libgit2.sh b/script/build-libgit2.sh index dd11314..9df8c3c 100755 --- a/script/build-libgit2.sh +++ b/script/build-libgit2.sh @@ -46,6 +46,11 @@ if [ -z "${BUILD_SHARED_LIBS}" ]; then usage fi +if [ -n "${BUILD_LIBGIT_REF}" ]; then + git -C "${VENDORED_PATH}" checkout "${BUILD_LIBGIT_REF}" + trap "git submodule update --init" EXIT +fi + if [ "${BUILD_SYSTEM}" = "ON" ]; then BUILD_INSTALL_PREFIX=${SYSTEM_INSTALL_PREFIX-"/usr"} else