Skip to content

Commit d71790c

Browse files
authored
refactor: switch the go-git to git2go for better performance (#172)
Signed-off-by: chlins <[email protected]>
1 parent 46a44c8 commit d71790c

File tree

5 files changed

+81
-102
lines changed

5 files changed

+81
-102
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,25 @@ jobs:
2929
with:
3030
go-version-file: go.mod
3131

32+
- name: Install dependencies
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y pkg-config
36+
sudo apt update && \
37+
sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential cmake pkg-config libssl-dev libssh2-1-dev zlib1g-dev libhttp-parser-dev python3 wget tar git && \
38+
wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.5.1.tar.gz -O libgit2-v1.5.1.tar.gz && \
39+
tar -xzf libgit2-v1.5.1.tar.gz && \
40+
cd libgit2-1.5.1 && \
41+
mkdir build && \
42+
cd build && \
43+
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF && \
44+
make -j$(nproc) && \
45+
sudo make install && \
46+
sudo ldconfig
47+
env:
48+
LIBGIT2_SYS_USE_PKG_CONFIG: "1"
49+
3250
- name: Run Unit tests
3351
run: |-
3452
go version
35-
go test -v ./...
53+
go test -ldflags '-extldflags "-static"' -tags static,system_libgit2 -v ./...

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ jobs:
2020
with:
2121
fetch-depth: '0'
2222

23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y pkg-config
27+
sudo apt update && \
28+
sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential cmake pkg-config libssl-dev libssh2-1-dev zlib1g-dev libhttp-parser-dev python3 wget tar git && \
29+
wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.5.1.tar.gz -O libgit2-v1.5.1.tar.gz && \
30+
tar -xzf libgit2-v1.5.1.tar.gz && \
31+
cd libgit2-1.5.1 && \
32+
mkdir build && \
33+
cd build && \
34+
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF && \
35+
make -j$(nproc) && \
36+
sudo make install && \
37+
sudo ldconfig
38+
env:
39+
LIBGIT2_SYS_USE_PKG_CONFIG: "1"
40+
2341
- name: Golangci lint
2442
uses: golangci/[email protected]
2543
with:

go.mod

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/distribution/reference v0.6.0
1111
github.com/dustin/go-humanize v1.0.1
1212
github.com/emirpasic/gods v1.18.1
13-
github.com/go-git/go-git/v5 v5.16.0
13+
github.com/libgit2/git2go/v34 v34.0.0
1414
github.com/minio/sha256-simd v1.0.1
1515
github.com/opencontainers/go-digest v1.0.0
1616
github.com/opencontainers/image-spec v1.1.1
@@ -25,57 +25,45 @@ require (
2525
)
2626

2727
require (
28-
dario.cat/mergo v1.0.0 // indirect
29-
github.com/Microsoft/go-winio v0.6.2 // indirect
30-
github.com/ProtonMail/go-crypto v1.1.6 // indirect
3128
github.com/VividCortex/ewma v1.2.0 // indirect
3229
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
3330
github.com/beorn7/perks v1.0.1 // indirect
3431
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
3532
github.com/cespare/xxhash/v2 v2.3.0 // indirect
36-
github.com/cloudflare/circl v1.6.1 // indirect
37-
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
3833
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3934
github.com/docker/go-metrics v0.0.1 // indirect
4035
github.com/fatih/color v1.7.0 // indirect
4136
github.com/fsnotify/fsnotify v1.8.0 // indirect
42-
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
43-
github.com/go-git/go-billy/v5 v5.6.2 // indirect
4437
github.com/go-logr/logr v1.4.2 // indirect
4538
github.com/go-logr/stdr v1.2.2 // indirect
4639
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
47-
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
40+
github.com/google/go-cmp v0.7.0 // indirect
4841
github.com/google/uuid v1.6.0 // indirect
4942
github.com/gorilla/mux v1.8.2-0.20240619235004-db9d1d0073d2 // indirect
5043
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
5144
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
5245
github.com/inconshreveable/mousetrap v1.1.0 // indirect
53-
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
54-
github.com/kevinburke/ssh_config v1.2.0 // indirect
5546
github.com/klauspost/compress v1.17.11 // indirect
5647
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
5748
github.com/mattn/go-colorable v0.1.2 // indirect
5849
github.com/mattn/go-isatty v0.0.8 // indirect
5950
github.com/mattn/go-runewidth v0.0.16 // indirect
6051
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6152
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
62-
github.com/pjbgf/sha1cd v0.3.2 // indirect
6353
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
6454
github.com/prometheus/client_golang v1.20.5 // indirect
6555
github.com/prometheus/client_model v0.6.1 // indirect
6656
github.com/prometheus/common v0.60.1 // indirect
6757
github.com/prometheus/procfs v0.15.1 // indirect
6858
github.com/rivo/uniseg v0.4.7 // indirect
59+
github.com/rogpeppe/go-internal v1.14.1 // indirect
6960
github.com/sagikazarmark/locafero v0.7.0 // indirect
70-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
71-
github.com/skeema/knownhosts v1.3.1 // indirect
7261
github.com/sourcegraph/conc v0.3.0 // indirect
7362
github.com/spf13/afero v1.12.0 // indirect
7463
github.com/spf13/cast v1.7.1 // indirect
7564
github.com/spf13/pflag v1.0.6 // indirect
7665
github.com/stretchr/objx v0.5.2 // indirect
7766
github.com/subosito/gotenv v1.6.0 // indirect
78-
github.com/xanzy/ssh-agent v0.3.3 // indirect
7967
go.opentelemetry.io/contrib/bridges/prometheus v0.57.0 // indirect
8068
go.opentelemetry.io/contrib/exporters/autoexport v0.57.0 // indirect
8169
go.opentelemetry.io/otel v1.32.0 // indirect
@@ -106,6 +94,5 @@ require (
10694
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
10795
google.golang.org/grpc v1.68.0 // indirect
10896
google.golang.org/protobuf v1.36.1 // indirect
109-
gopkg.in/warnings.v0 v0.1.2 // indirect
11097
gopkg.in/yaml.v3 v3.0.1 // indirect
11198
)

0 commit comments

Comments
 (0)