Skip to content

Commit 7f969dc

Browse files
Merge pull request #266 from mergestat/vendor-libgit2
feat: vendor `libgit2` (via `git2go`)
2 parents 25d389e + 4395283 commit 7f969dc

File tree

9 files changed

+21
-12
lines changed

9 files changed

+21
-12
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ jobs:
2828

2929
- name: Check out source
3030
uses: actions/checkout@v1
31+
with:
32+
submodules: recursive
3133

3234
- name: Install libgit2
33-
run: sudo ./scripts/install_libgit2.sh
35+
run: make libgit2
3436

3537
- name: Build
3638
run: make

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ jobs:
2121

2222
- name: Check out source
2323
uses: actions/checkout@v1
24+
with:
25+
submodules: recursive
2426

2527
- name: Install libgit2
26-
run: sudo ./scripts/install_libgit2.sh
28+
run: make libgit2
2729

2830
- name: Vet
2931
run: make vet

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "git2go"]
2+
path = git2go
3+
url = https://github.com/libgit2/git2go

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"go.buildFlags": [
33
"-tags='libsqlite3'"
44
],
5-
"go.testFlags": ["-v", "-tags=libsqlite3,static,system_libgit2"],
5+
"go.testFlags": ["-v", "-tags=libsqlite3,static"],
66
"go.vetFlags": ["-tags=libsqlite3"],
77
"go.toolsEnvVars": {
88
"GOFLAGS": "-tags='libsqlite3'",

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
FROM golang:1.17-buster as builder
22
WORKDIR /app
3-
COPY scripts .
43
RUN apt-get update && apt-get -y install cmake libssl-dev
5-
RUN ./install_libgit2.sh
6-
COPY go.mod go.sum ./
7-
RUN go mod download
84
COPY . .
5+
RUN make libgit2
96
RUN make
107

118
FROM debian:buster-slim

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ ifeq ($(shell uname -s),Darwin)
1111
export CGO_LDFLAGS = -Wl,-undefined,dynamic_lookup
1212
endif
1313

14+
# target to build and install libgit2
15+
libgit2:
16+
cd git2go; make install-static
17+
1418
# target to build a dynamic extension that can be loaded at runtime
1519
.build/libmergestat.so: $(shell find . -type f -name '*.go' -o -name '*.c')
1620
$(call log, $(CYAN), "building $@")
17-
@go build -buildmode=c-shared -o $@ -tags="system_libgit2,shared" shared.go
21+
@go build -buildmode=c-shared -o $@ -tags="static,shared" shared.go
1822
$(call log, $(GREEN), "built $@")
1923

2024
# target to compile mergestat executable
2125
.build/mergestat: $(shell find . -type f -name '*.go' -o -name '*.c')
2226
$(call log, $(CYAN), "building $@")
23-
@go build -o $@ -tags="static,system_libgit2" mergestat.go
27+
@go build -o $@ -tags="static" mergestat.go
2428
$(call log, $(GREEN), "built $@")
2529

2630
# target to download latest sqlite3 amalgamation code
@@ -43,7 +47,7 @@ clean:
4347
# target for common golang tasks
4448

4549
# go build tags used by test, vet and more
46-
TAGS = "static,system_libgit2"
50+
TAGS = "static"
4751

4852
update:
4953
go get -tags=$(TAGS) -u ./...

git2go

Submodule git2go added at eae0077

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ require (
7575
gopkg.in/warnings.v0 v0.1.2 // indirect
7676
gopkg.in/yaml.v2 v2.4.0 // indirect
7777
)
78+
79+
replace github.com/libgit2/git2go/v33 => ./git2go

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,6 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+
342342
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
343343
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
344344
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
345-
github.com/libgit2/git2go/v33 v33.0.9 h1:4ch2DJed6IhJO28BEohkUoGvxLsRzUjxljoNFJ6/O78=
346-
github.com/libgit2/git2go/v33 v33.0.9/go.mod h1:KdpqkU+6+++4oHna/MIOgx4GCQ92IPCdpVRMRI80J+4=
347345
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
348346
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
349347
github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w=

0 commit comments

Comments
 (0)