Skip to content

Commit 1fabe95

Browse files
authored
Relax libgit2 minor version check (#696)
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
1 parent 7497529 commit 1fabe95

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ jobs:
9191
build-system-dynamic:
9292
strategy:
9393
fail-fast: false
94+
matrix:
95+
libgit2: [ '1.1.0' ]
9496
name: Go (system-wide, dynamic)
9597

9698
runs-on: ubuntu-20.04
@@ -103,10 +105,10 @@ jobs:
103105
id: go
104106
- name: Check out code into the Go module directory
105107
uses: actions/checkout@v1
106-
- name: Build libgit2
108+
- name: Build libgit2 ${{ matrix.libgit2 }}
107109
run: |
108110
git submodule update --init
109-
sudo ./script/build-libgit2.sh --dynamic --system
111+
sudo env BUILD_LIBGIT_REF=v${{ matrix.libgit2 }} ./script/build-libgit2.sh --dynamic --system
110112
- name: Test
111113
run: make test
112114

git_bundled_static.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ package git
99
#cgo CFLAGS: -DLIBGIT2_STATIC
1010
#include <git2.h>
1111
12-
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 1
13-
# error "Invalid libgit2 version; this git2go supports libgit2 v1.1"
12+
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 1 || LIBGIT2_VER_MINOR > 1
13+
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.1.0 and v1.1.0"
1414
#endif
1515
*/
1616
import "C"

git_system_dynamic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ package git
77
#cgo CFLAGS: -DLIBGIT2_DYNAMIC
88
#include <git2.h>
99
10-
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 1
11-
# error "Invalid libgit2 version; this git2go supports libgit2 v1.1"
10+
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 1 || LIBGIT2_VER_MINOR > 1
11+
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.1.0 and v1.1.0"
1212
#endif
1313
*/
1414
import "C"

git_system_static.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ package git
77
#cgo CFLAGS: -DLIBGIT2_STATIC
88
#include <git2.h>
99
10-
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR != 1
11-
# error "Invalid libgit2 version; this git2go supports libgit2 v1.1"
10+
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 1 || LIBGIT2_VER_MINOR > 1
11+
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.1.0 and v1.1.0"
1212
#endif
1313
*/
1414
import "C"

script/build-libgit2.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ if [ -z "${BUILD_SHARED_LIBS}" ]; then
4646
usage
4747
fi
4848

49+
if [ -n "${BUILD_LIBGIT_REF}" ]; then
50+
git -C "${VENDORED_PATH}" checkout "${BUILD_LIBGIT_REF}"
51+
trap "git submodule update --init" EXIT
52+
fi
53+
4954
if [ "${BUILD_SYSTEM}" = "ON" ]; then
5055
BUILD_INSTALL_PREFIX=${SYSTEM_INSTALL_PREFIX-"/usr"}
5156
else

0 commit comments

Comments
 (0)