Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-08-26 08:42:36 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-08-26 08:42:36 +0300
commitc681e8d76689516be2e4f141a48fb11f13273884 (patch)
treefb7e5929fd3cc8da5a9aaa2d1cfa7d22f04e206e
parent95dd747b9eb93f75a2af155050f1cbc39a2f11ab (diff)
parentecf264e07f622a0dd55dda363ef6c0fecc228668 (diff)
Merge branch 'pks-reenable-git2go' into 'master'
Reenable Git2Go integration See merge request gitlab-org/gitaly!2438
-rw-r--r--.gitignore1
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--Makefile46
-rw-r--r--NOTICE24
-rw-r--r--changelogs/unreleased/pks-reenable-git2go.yml5
-rw-r--r--cmd/gitaly-git2go/main.go25
-rw-r--r--go.mod1
-rw-r--r--go.sum3
8 files changed, 104 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 25909590c..35e7aeb1f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
/_build
/config.mak
/gitaly
+/gitaly-git2go
/gitaly-hooks
cmd/gitaly-ssh/gitaly-ssh
/gitaly-ssh
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f86367f76..8b011e8cb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -34,6 +34,8 @@ danger-review:
- Makefile
- ruby/Gemfile.lock
paths:
+ - _build/libgit2
+ - _build/Makefile.sha256
- ruby/vendor/bundle
.build_template: &build_definition
@@ -70,6 +72,8 @@ danger-review:
- Makefile
- ruby/Gemfile.lock
paths:
+ - _build/libgit2
+ - _build/Makefile.sha256
- ruby/vendor/bundle
policy: pull
artifacts:
diff --git a/Makefile b/Makefile
index b006ec692..f5f600a4f 100644
--- a/Makefile
+++ b/Makefile
@@ -51,13 +51,14 @@ BUILD_TIME := $(shell date +"%Y%m%d.%H%M%S")
GITALY_VERSION := $(shell git describe --match v* 2>/dev/null | sed 's/^v//' || cat ${SOURCE_DIR}/VERSION 2>/dev/null || echo unknown)
GO_LDFLAGS := -ldflags '-X ${GITALY_PACKAGE}/internal/version.version=${GITALY_VERSION} -X ${GITALY_PACKAGE}/internal/version.buildtime=${BUILD_TIME}'
GO_TEST_LDFLAGS := -X gitlab.com/gitlab-org/gitaly/auth.timestampThreshold=5s
-GO_BUILD_TAGS := tracer_static,tracer_static_jaeger,continuous_profiler_stackdriver
+GO_BUILD_TAGS := tracer_static,tracer_static_jaeger,continuous_profiler_stackdriver,static,system_libgit2
# Dependency versions
GOLANGCI_LINT_VERSION ?= 1.27.0
PROTOC_VERSION ?= 3.12.4
PROTOC_GEN_GO_VERSION ?= 1.3.2
GIT_VERSION ?= v2.27.0
+LIBGIT2_VERSION ?= v1.0.1
# Dependency downloads
ifeq (${OS},Darwin)
@@ -91,6 +92,30 @@ ifeq (${GIT_BUILD_OPTIONS},)
GIT_BUILD_OPTIONS += NO_R_TO_GCC_LINKER=YesPlease
endif
+# libgit2 target
+LIBGIT2_REPO_URL ?= https://gitlab.com/libgit2/libgit2
+LIBGIT2_SOURCE_DIR ?= ${BUILD_DIR}/src/libgit2
+LIBGIT2_BUILD_DIR ?= ${LIBGIT2_SOURCE_DIR}/build
+LIBGIT2_INSTALL_DIR ?= ${BUILD_DIR}/libgit2
+
+ifeq (${LIBGIT2_BUILD_OPTIONS},)
+ LIBGIT2_BUILD_OPTIONS += -DTHREADSAFE=ON
+ LIBGIT2_BUILD_OPTIONS += -DBUILD_CLAR=OFF
+ LIBGIT2_BUILD_OPTIONS += -DBUILD_SHARED_LIBS=OFF
+ LIBGIT2_BUILD_OPTIONS += -DCMAKE_C_FLAGS=-fPIC
+ LIBGIT2_BUILD_OPTIONS += -DCMAKE_BUILD_TYPE=Release
+ LIBGIT2_BUILD_OPTIONS += -DCMAKE_INSTALL_PREFIX=${LIBGIT2_INSTALL_DIR}
+ LIBGIT2_BUILD_OPTIONS += -DCMAKE_INSTALL_LIBDIR=lib
+ LIBGIT2_BUILD_OPTIONS += -DENABLE_TRACE=OFF
+ LIBGIT2_BUILD_OPTIONS += -DUSE_SSH=OFF
+ LIBGIT2_BUILD_OPTIONS += -DUSE_HTTPS=OFF
+ LIBGIT2_BUILD_OPTIONS += -DUSE_ICONV=OFF
+ LIBGIT2_BUILD_OPTIONS += -DUSE_NTLMCLIENT=OFF
+ LIBGIT2_BUILD_OPTIONS += -DUSE_BUNDLED_ZLIB=ON
+ LIBGIT2_BUILD_OPTIONS += -DUSE_HTTP_PARSER=builtin
+ LIBGIT2_BUILD_OPTIONS += -DREGEX_BACKEND=builtin
+endif
+
# These variables control test options and artifacts
TEST_OPTIONS ?=
TEST_REPORT_DIR ?= ${BUILD_DIR}/reports
@@ -115,6 +140,7 @@ unexport GOROOT
export GOBIN = ${BUILD_DIR}/bin
export GOPROXY ?= https://proxy.golang.org
export PATH := ${BUILD_DIR}/bin:${PATH}
+export PKG_CONFIG_PATH := ${LIBGIT2_INSTALL_DIR}/lib/pkgconfig
export GITALY_TESTING_GIT_BINARY ?= ${GIT}
.NOTPARALLEL:
@@ -124,7 +150,7 @@ all: INSTALL_DEST_DIR = ${SOURCE_DIR}
all: install
.PHONY: build
-build: ${SOURCE_DIR}/.ruby-bundle
+build: ${SOURCE_DIR}/.ruby-bundle libgit2
go install ${GO_LDFLAGS} -tags "${GO_BUILD_TAGS}" $(addprefix ${GITALY_PACKAGE}/cmd/, $(call find_commands))
.PHONY: install
@@ -172,7 +198,7 @@ test: export PATH := ${SOURCE_DIR}/internal/testhelper/testdata/home/bin:${PATH}
test: test-go rspec rspec-gitlab-shell
.PHONY: test-go
-test-go: prepare-tests ${GO_JUNIT_REPORT}
+test-go: prepare-tests ${GO_JUNIT_REPORT} libgit2
${Q}mkdir -p ${TEST_REPORT_DIR}
${Q}echo 0>${TEST_EXIT}
${Q}go test ${TEST_OPTIONS} -v -tags "${GO_BUILD_TAGS}" -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) 2>&1 | tee ${TEST_OUTPUT} || echo $$? >${TEST_EXIT}
@@ -213,7 +239,7 @@ check-mod-tidy:
${Q}${GIT} diff --quiet --exit-code go.mod go.sum || (echo "error: uncommitted changes in go.mod or go.sum" && exit 1)
.PHONY: lint
-lint: ${GOLANGCI_LINT}
+lint: ${GOLANGCI_LINT} libgit2
${Q}${GOLANGCI_LINT} cache clean && ${GOLANGCI_LINT} run --build-tags "${GO_BUILD_TAGS}" --out-format tab --config ${SOURCE_DIR}/.golangci.yml
.PHONY: check-formatting
@@ -256,7 +282,7 @@ rubocop: ${SOURCE_DIR}/.ruby-bundle
${Q}cd ${GITALY_RUBY_DIR} && bundle exec rubocop --parallel
.PHONY: cover
-cover: prepare-tests
+cover: prepare-tests libgit2
${Q}echo "NOTE: make cover does not exit 1 on failure, don't use it to check for tests success!"
${Q}mkdir -p "${COVERAGE_DIR}"
${Q}rm -f "${COVERAGE_DIR}/all.merged" "${COVERAGE_DIR}/all.html"
@@ -317,6 +343,9 @@ build-git:
${Q}mkdir -p ${GIT_INSTALL_DIR}
${MAKE} -C ${GIT_SOURCE_DIR} -j$(shell nproc) prefix=${GIT_PREFIX} ${GIT_BUILD_OPTIONS} install
+.PHONY: libgit2
+libgit2: ${LIBGIT2_INSTALL_DIR}/lib/libgit2.a
+
# This file is used by Omnibus and CNG to skip the "bundle install"
# step. Both Omnibus and CNG assume it is in the Gitaly root, not in
# _build. Hence the '../' in front.
@@ -365,6 +394,13 @@ ${BUILD_DIR}/git_full_bins.tgz: ${BUILD_DIR}/Makefile.sha256
${Q}printf '${GIT_BINARIES_HASH} $@.tmp' | sha256sum -c -
${Q}mv $@.tmp $@
+${LIBGIT2_INSTALL_DIR}/lib/libgit2.a: ${BUILD_DIR}/Makefile.sha256
+ ${Q}rm -rf ${LIBGIT2_SOURCE_DIR}
+ git clone --depth 1 --branch ${LIBGIT2_VERSION} --quiet ${LIBGIT2_REPO_URL} ${LIBGIT2_SOURCE_DIR}
+ ${Q}mkdir -p ${LIBGIT2_BUILD_DIR}
+ ${Q}cd ${LIBGIT2_BUILD_DIR} && cmake ${LIBGIT2_SOURCE_DIR} ${LIBGIT2_BUILD_OPTIONS}
+ ${Q}CMAKE_BUILD_PARALLEL_LEVEL=$(shell nproc) cmake --build ${LIBGIT2_BUILD_DIR} --target install
+
${GOIMPORTS}: ${BUILD_DIR}/Makefile.sha256 ${BUILD_DIR}/go.mod
${Q}cd ${BUILD_DIR} && go get golang.org/x/tools/cmd/goimports@2538eef75904eff384a2551359968e40c207d9d2
diff --git a/NOTICE b/NOTICE
index d71218846..81db0288b 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1329,6 +1329,30 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED &#34;AS IS&#34;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+LICENSE - github.com/libgit2/git2go/v30
+The MIT License
+
+Copyright (c) 2013 The git2go contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the &#34;Software&#34;), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED &#34;AS IS&#34;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LICENSE - github.com/mattn/go-runewidth
The MIT License (MIT)
diff --git a/changelogs/unreleased/pks-reenable-git2go.yml b/changelogs/unreleased/pks-reenable-git2go.yml
new file mode 100644
index 000000000..94854502c
--- /dev/null
+++ b/changelogs/unreleased/pks-reenable-git2go.yml
@@ -0,0 +1,5 @@
+---
+title: Add Git2Go integration
+merge_request: 2438
+author:
+type: added
diff --git a/cmd/gitaly-git2go/main.go b/cmd/gitaly-git2go/main.go
new file mode 100644
index 000000000..bc25dc67c
--- /dev/null
+++ b/cmd/gitaly-git2go/main.go
@@ -0,0 +1,25 @@
+// +build static,system_libgit2
+
+package main
+
+import (
+ "os"
+
+ git "github.com/libgit2/git2go/v30"
+)
+
+func main() {
+ repo, err := git.OpenRepository(".")
+ if err != nil {
+ os.Exit(1)
+ }
+ defer repo.Free()
+
+ head, err := repo.Head()
+ if err != nil {
+ os.Exit(1)
+ }
+ defer head.Free()
+
+ println(head.Target().String())
+}
diff --git a/go.mod b/go.mod
index c9581053b..dfc6b0e6a 100644
--- a/go.mod
+++ b/go.mod
@@ -11,6 +11,7 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/kelseyhightower/envconfig v1.3.0
github.com/lib/pq v1.2.0
+ github.com/libgit2/git2go/v30 v30.0.5
github.com/olekukonko/tablewriter v0.0.2
github.com/otiai10/curr v1.0.0 // indirect
github.com/prometheus/client_golang v1.0.0
diff --git a/go.sum b/go.sum
index c91a01b46..5c96bf646 100644
--- a/go.sum
+++ b/go.sum
@@ -199,7 +199,10 @@ github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvf
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/libgit2/git2go v0.0.0-20190104134018-ecaeb7a21d47 h1:HDt7WT3kpXSHq4mlOuLzgXH9LeOK1qlhyFdKIAzxxeM=
github.com/libgit2/git2go v0.0.0-20190104134018-ecaeb7a21d47/go.mod h1:4bKN42efkbNYMZlvDfxGDxzl066GhpvIircZDsm8Y+Y=
+github.com/libgit2/git2go/v30 v30.0.5 h1:gxKqXOslpvYDZNC62f8GV34TAk0qw4wZ++IdYw8V9I4=
+github.com/libgit2/git2go/v30 v30.0.5/go.mod h1:YReiQ7xhMoyAL4ISYFLZt+OGqn6xtLqvTC1xJ9oAH7Y=
github.com/lightstep/lightstep-tracer-go v0.15.6 h1:D0GGa7afJ7GcQvu5as6ssLEEKYXvRgKI5d5cevtz8r4=
github.com/lightstep/lightstep-tracer-go v0.15.6/go.mod h1:6AMpwZpsyCFwSovxzM78e+AsYxE8sGwiM6C3TytaWeI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=