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-03 09:01:57 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-08-03 09:01:57 +0300
commitdef4d6bed725d40bbc8455bb954e03ab547b1105 (patch)
treed2d9018efc6e6de161d761eaad7adf8417192482
parenta6091637dcb4c3b601a8860b5f164c0ce90ba0ca (diff)
Revert "Merge branch 'pks-revert-git2go' into 'master'"
This reverts commit a6091637dcb4c3b601a8860b5f164c0ce90ba0ca, reversing changes made to 8c1db4da3a6636dffdae7d337e0aba8b1c399482.
-rw-r--r--.gitignore1
-rw-r--r--.gitlab-ci.yml20
-rw-r--r--Makefile61
-rw-r--r--NOTICE24
-rw-r--r--changelogs/unreleased/pks-libgit2-iconv.yml5
-rw-r--r--cmd/gitaly-git2go/main.go23
-rw-r--r--ctxt.BuildTags5
-rw-r--r--go.mod1
-rw-r--r--go.sum3
9 files changed, 128 insertions, 15 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 f8688418d..614cd15ea 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,13 +29,25 @@ danger-review:
.ruby_template: &ruby_definition
cache:
- key: gems-ruby-2.6
+ key:
+ files:
+ - Makefile
+ - ruby/Gemfile.lock
paths:
+ - _build/libgit2
- ruby/vendor/bundle
.build_template: &build_definition
<<: *ruby_definition
stage: build
+ cache:
+ key:
+ files:
+ - Makefile
+ - ruby/Gemfile.lock
+ paths:
+ - _build/libgit2
+ - ruby/vendor/bundle
script:
- go version
- make
@@ -62,8 +74,12 @@ danger-review:
stage: test
# Override the ruby_definition cache definition for pull
cache:
- key: gems-ruby-2.6
+ key:
+ files:
+ - Makefile
+ - ruby/Gemfile.lock
paths:
+ - _build/libgit2
- ruby/vendor/bundle
policy: pull
artifacts:
diff --git a/Makefile b/Makefile
index a823a01c0..b87d06ce2 100644
--- a/Makefile
+++ b/Makefile
@@ -50,13 +50,13 @@ 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
# Dependency versions
GOLANGCI_LINT_VERSION ?= 1.27.0
PROTOC_VERSION ?= 3.6.1
PROTOC_GEN_GO_VERSION ?= 1.3.2
GIT_VERSION ?= v2.27.0
+LIBGIT2_VERSION ?= v1.0.1
# Dependency downloads
ifeq (${OS},Darwin)
@@ -90,6 +90,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
@@ -111,9 +135,10 @@ find_go_sources = $(shell find ${SOURCE_DIR} -type d \( -name ruby -o -name ven
find_go_packages = $(dir $(call find_go_sources, 's|[^/]*\.go||'))
unexport GOROOT
-export GOBIN = ${BUILD_DIR}/bin
-export GOPROXY ?= https://proxy.golang.org
-export PATH := ${BUILD_DIR}/bin:${PATH}
+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
.NOTPARALLEL:
@@ -122,8 +147,8 @@ all: INSTALL_DEST_DIR = ${SOURCE_DIR}
all: install
.PHONY: build
-build: ${SOURCE_DIR}/.ruby-bundle
- go install ${GO_LDFLAGS} -tags "${GO_BUILD_TAGS}" $(addprefix ${GITALY_PACKAGE}/cmd/, $(call find_commands))
+build: ${SOURCE_DIR}/.ruby-bundle libgit2
+ go install ${GO_LDFLAGS} $(addprefix ${GITALY_PACKAGE}/cmd/, $(call find_commands))
.PHONY: install
install: build
@@ -169,20 +194,20 @@ prepare-tests: ${GITLAB_SHELL_DIR}/config.yml ${TEST_REPO} ${TEST_REPO_GIT} ${SO
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}
+ ${Q}go test ${TEST_OPTIONS} -v -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) 2>&1 | tee ${TEST_OUTPUT} || echo $$? >${TEST_EXIT}
${Q}${GO_JUNIT_REPORT} <${TEST_OUTPUT} >${TEST_REPORT}
${Q}exit `cat ${TEST_EXIT}`
.PHONY: test-with-proxies
test-with-proxies: prepare-tests
- ${Q}go test -tags "${GO_BUILD_TAGS}" -count=1 -exec ${SOURCE_DIR}/_support/bad-proxies ${GITALY_PACKAGE}/internal/rubyserver/
+ ${Q}go test -count=1 -exec ${SOURCE_DIR}/_support/bad-proxies ${GITALY_PACKAGE}/internal/rubyserver/
.PHONY: test-with-praefect
test-with-praefect: build prepare-tests
- ${Q}GITALY_TEST_PRAEFECT_BIN=${BUILD_DIR}/bin/praefect go test -tags "${GO_BUILD_TAGS}" -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) # count=1 bypasses go 1.10 test caching
+ ${Q}GITALY_TEST_PRAEFECT_BIN=${BUILD_DIR}/bin/praefect go test -ldflags='${GO_TEST_LDFLAGS}' -count=1 $(call find_go_packages) # count=1 bypasses go 1.10 test caching
.PHONY: race-go
race-go: TEST_OPTIONS = -race
@@ -208,7 +233,7 @@ check-mod-tidy:
${Q}${SOURCE_DIR}/_support/check-mod-tidy
.PHONY: lint
-lint: ${GOLANGCI_LINT}
+lint: ${GOLANGCI_LINT} libgit2
${Q}${GOLANGCI_LINT} cache clean && ${GOLANGCI_LINT} run --out-format tab --config ${SOURCE_DIR}/.golangci.yml
.PHONY: check-formatting
@@ -251,7 +276,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"
@@ -270,7 +295,7 @@ docker:
cp -r ${GITALY_RUBY_DIR} ${BUILD_DIR}/docker/ruby
${Q}rm -rf ${BUILD_DIR}/docker/ruby/vendor/bundle
for command in $(call find_commands); do \
- GOOS=linux GOARCH=amd64 go build -tags "${GO_BUILD_TAGS}" ${GO_LDFLAGS} -o "${BUILD_DIR}/docker/bin/$${command}" ${GITALY_PACKAGE}/cmd/$${command}; \
+ GOOS=linux GOARCH=amd64 go build ${GO_LDFLAGS} -o "${BUILD_DIR}/docker/bin/$${command}" ${GITALY_PACKAGE}/cmd/$${command}; \
done
cp ${SOURCE_DIR}/Dockerfile ${BUILD_DIR}/docker/
docker build -t gitlab/gitaly:v${GITALY_VERSION} -t gitlab/gitaly:latest ${BUILD_DIR}/docker/
@@ -312,6 +337,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.
@@ -353,6 +381,13 @@ ${BUILD_DIR}/git_full_bins.tgz: | ${BUILD_DIR}
${Q}printf '${GIT_BINARIES_HASH} $@.tmp' | shasum -a256 -c -
${Q}mv $@.tmp $@
+${LIBGIT2_INSTALL_DIR}/lib/libgit2.a:
+ ${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 ${LIBGIT2_BUILD_DIR} --target install
+
${GOIMPORTS}: ${BUILD_DIR}/go.mod | ${BUILD_DIR}/bin
${Q}cd ${BUILD_DIR} && go get golang.org/x/tools/cmd/goimports@2538eef75904eff384a2551359968e40c207d9d2
diff --git a/NOTICE b/NOTICE
index e1f52bd1d..7e3c31f9a 100644
--- a/NOTICE
+++ b/NOTICE
@@ -671,6 +671,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-libgit2-iconv.yml b/changelogs/unreleased/pks-libgit2-iconv.yml
new file mode 100644
index 000000000..25c30787f
--- /dev/null
+++ b/changelogs/unreleased/pks-libgit2-iconv.yml
@@ -0,0 +1,5 @@
+---
+title: Disable iconv support for libgit2
+merge_request: 2434
+author:
+type: fixed
diff --git a/cmd/gitaly-git2go/main.go b/cmd/gitaly-git2go/main.go
new file mode 100644
index 000000000..a11cfcad8
--- /dev/null
+++ b/cmd/gitaly-git2go/main.go
@@ -0,0 +1,23 @@
+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/ctxt.BuildTags b/ctxt.BuildTags
new file mode 100644
index 000000000..6deb1ea8a
--- /dev/null
+++ b/ctxt.BuildTags
@@ -0,0 +1,5 @@
+continuous_profiler_stackdriver
+static
+system_libgit2
+tracer_static
+tracer_static_jaeger
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=