diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | NOTICE | 24 | ||||
-rw-r--r-- | _support/Makefile.template | 28 | ||||
-rw-r--r-- | _support/makegen.go | 24 | ||||
-rw-r--r-- | changelogs/unreleased/pks-gitaly-remote-removal.yml | 5 | ||||
-rw-r--r-- | cmd/gitaly-remote/add_test.go | 57 | ||||
-rw-r--r-- | cmd/gitaly-remote/main.go | 67 | ||||
-rw-r--r-- | go.mod | 1 | ||||
-rw-r--r-- | go.sum | 2 |
11 files changed, 5 insertions, 216 deletions
diff --git a/.gitignore b/.gitignore index dcae30693..a8f8f0b3f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,6 @@ cmd/gitaly-ssh/gitaly-ssh /gitaly-ssh cmd/gitaly-wrapper/gitaly-wrapper /gitaly-wrapper -cmd/gitaly-remote/gitaly-remote -/gitaly-remote **/testdata/gitaly-libexec/ /*.deb /_support/package/bin @@ -24,7 +22,6 @@ git-env /gitaly-debug /praefect gitaly.pid -/vendor/github.com/libgit2/git2go/vendor /vendor /gitaly-*.gem /gitaly-blackbox diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09e6159b5..119e4334e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,6 @@ danger-review: script: - go version - make - - echo 'make build-gitaly-remote TODO https://gitlab.com/gitlab-org/gitaly/issues/1706' - _support/test-boot . .assemble_template: &assemble_definition @@ -78,7 +77,6 @@ danger-review: - go version - git version - make test - - echo 'make test-gitaly-remote TODO https://gitlab.com/gitlab-org/gitaly/issues/1706' artifacts: paths: - report-${CI_JOB_NAME}.xml @@ -32,14 +32,6 @@ all: build build: prepare-build cd $(BUILD_DIR) && $(MAKE) install INSTALL_DEST_DIR=$(CURDIR) -.PHONY: build-gitaly-remote -build-gitaly-remote: prepare-build - cd $(BUILD_DIR) && $(MAKE) $@ - -.PHONY: test-gitaly-remote -test-gitaly-remote: prepare-build - cd $(BUILD_DIR) && $(MAKE) $@ - .PHONY: install install: prepare-build cd $(BUILD_DIR) && $(MAKE) $@ @@ -671,30 +671,6 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", 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 -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 "Software"), 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 "AS IS", 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/matttproud/golang_protobuf_extensions/pbutil Apache License Version 2.0, January 2004 diff --git a/_support/Makefile.template b/_support/Makefile.template index 7bbf2d4c1..c6c164025 100644 --- a/_support/Makefile.template +++ b/_support/Makefile.template @@ -23,30 +23,6 @@ export PATH := {{ .BuildDir }}/bin:$(PATH) .PHONY: all all: build -{{ .Git2GoVendorDir }}/.ok: - rm -rf {{ .Git2GoVendorDir }} - mkdir -p {{ .Git2GoVendorDir }} - - cd {{ .Git2GoVendorDir }} && curl -L -o libgit2.tar.gz https://github.com/libgit2/libgit2/archive/v{{ .LibGit2Version }}.tar.gz - cd {{ .Git2GoVendorDir }} && echo '{{ .LibGit2SHA }} libgit2.tar.gz' | shasum -a256 -c - - cd {{ .Git2GoVendorDir }} && tar -xvf libgit2.tar.gz - cd {{ .Git2GoVendorDir }} && mv libgit2-{{ .LibGit2Version }} libgit2 - - mkdir -p {{ .Git2GoVendorDir }}/libgit2/build - mkdir -p {{ .Git2GoVendorDir }}/libgit2/install/lib - cd {{ .Git2GoVendorDir }}/libgit2/build && cmake -DTHREADSAFE=ON -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX=../install .. - cd {{ .Git2GoVendorDir }}/libgit2/build && cmake --build . - - touch $@ - -.PHONY: build-gitaly-remote -build-gitaly-remote: {{ .Git2GoVendorDir }}/.ok - cd {{ .SourceDir }} && go install {{ .GoLdFlags }} -tags "$(BUILD_TAGS) static" {{ .GitalyRemotePackage }} - -.PHONY: test-gitaly-remote -test-gitaly-remote: prepare-tests {{ .Git2GoVendorDir }}/.ok - @go test -tags "$(BUILD_TAGS) static" -count=1 {{ .GitalyRemotePackage }} - .PHONY: build build: ../.ruby-bundle # go install @@ -164,10 +140,8 @@ check-mod-tidy: .PHONY: lint lint: {{ .GoLint }} @cd {{ .SourceDir }} && \ - git rm -r --quiet cmd/gitaly-remote; \ {{ .GoLint }} run --out-format tab --config .golangci.yml; \ EXIT_CODE=$$?;\ - git checkout --quiet --no-progress HEAD cmd/gitaly-remote; \ exit $$EXIT_CODE .PHONY: check-formatting @@ -198,10 +172,8 @@ format: {{ .GoImports }} {{ .GitalyFmt }} staticcheck-deprecations: {{ .GoLint }} # Only returns deprecated code usage @cd {{ .SourceDir }} && \ - git rm -r --quiet cmd/gitaly-remote; \ {{ .GoLint }} run --out-format tab --config _support/golangci.warnings.yml; \ EXIT_CODE=$$?;\ - git checkout --quiet --no-progress HEAD cmd/gitaly-remote; \ exit $$EXIT_CODE .PHONY: lint-warnings diff --git a/_support/makegen.go b/_support/makegen.go index d9e975bbe..57b6e39dc 100644 --- a/_support/makegen.go +++ b/_support/makegen.go @@ -94,18 +94,6 @@ func (gm *gitalyMake) GitlabShellDir() string { return filepath.Join(gm.SourceDir(), gm.GitlabShellRelDir()) } -func (gm *gitalyMake) Git2GoVendorDir() string { - return filepath.Join(gm.BuildDir(), "../vendor/github.com/libgit2/git2go/vendor") -} - -func (gm *gitalyMake) LibGit2Version() string { - return filepath.Join("0.27.8") -} - -func (gm *gitalyMake) LibGit2SHA() string { - return filepath.Join("8313873d49dc01e8b880ec334d7430ae67496a89aaa8c6e7bbd3affb47a00c76") -} - func (gm *gitalyMake) SourceDir() string { return os.Getenv("SOURCE_DIR") } @@ -122,10 +110,6 @@ func (gm *gitalyMake) GitTestRepo() string { return filepath.Join(gm.TestRepoStoragePath(), "gitlab-git-test.git") } -func (gm *gitalyMake) GitalyRemotePackage() string { - return filepath.Join(gm.Pkg(), "cmd", "gitaly-remote") -} - func (gm *gitalyMake) MakegenDep() string { return strings.Join([]string{ filepath.Join(gm.SourceDir(), "_support/makegen.go"), @@ -144,10 +128,6 @@ func (gm *gitalyMake) CommandPackages() []string { } for _, dir := range entries { - //Do not build gitaly-remote by default - if dir.Name() == "gitaly-remote" { - continue - } if !dir.IsDir() { continue } @@ -274,10 +254,6 @@ func (gm *gitalyMake) AllPackages() []string { var pkgs []string for k := range pkgMap { - //Do not build gitaly-remote by default - if k == "gitlab.com/gitlab-org/gitaly/cmd/gitaly-remote" { - continue - } pkgs = append(pkgs, k) } diff --git a/changelogs/unreleased/pks-gitaly-remote-removal.yml b/changelogs/unreleased/pks-gitaly-remote-removal.yml new file mode 100644 index 000000000..01137b2eb --- /dev/null +++ b/changelogs/unreleased/pks-gitaly-remote-removal.yml @@ -0,0 +1,5 @@ +--- +title: Remove gitaly-remote command +merge_request: 1992 +author: +type: removed diff --git a/cmd/gitaly-remote/add_test.go b/cmd/gitaly-remote/add_test.go deleted file mode 100644 index ca0eb8317..000000000 --- a/cmd/gitaly-remote/add_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "os" - "os/exec" - "strings" - "testing" - - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "gitlab.com/gitlab-org/gitaly/internal/testhelper" -) - -func buildGitRemote() { - // Build the test-binary that we need - os.Remove("gitaly-remote") - testhelper.MustRunCommand(nil, nil, "go", "build", "-tags", "static gitaly_remote", "gitlab.com/gitlab-org/gitaly/cmd/gitaly-remote") -} - -func TestAddRemote(t *testing.T) { - buildGitRemote() - - testCases := []struct { - name string - remote string - url string - }{ - { - name: "update-existing", - remote: "remote", - url: "https://test.server.com/test.git", - }, - { - name: "update-existing", - remote: "remote", - url: "https://test.server.com/test.git", - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - testRepo, _, cleanupFn := testhelper.NewTestRepo(t) - defer cleanupFn() - - repoPath, err := helper.GetRepoPath(testRepo) - require.NoError(t, err) - - cmd := exec.Command("./gitaly-remote", repoPath, tc.remote) - cmd.Stdin = strings.NewReader(tc.url) - err = cmd.Run() - require.NoError(t, err) - - out := testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "remote", "get-url", tc.remote) - require.Equal(t, tc.url, strings.TrimSpace(string(out))) - }) - } -} diff --git a/cmd/gitaly-remote/main.go b/cmd/gitaly-remote/main.go deleted file mode 100644 index 92ef802e6..000000000 --- a/cmd/gitaly-remote/main.go +++ /dev/null @@ -1,67 +0,0 @@ -package main - -import ( - "io/ioutil" - "log" - "os" - - git "github.com/libgit2/git2go" -) - -// echo "https://remote.url.com" | gitaly-remote /path/to/repository remote-name -func main() { - if n := len(os.Args); n != 3 { - log.Fatalf("invalid number of arguments, expected 2, got %d", n-1) - } - - repoPath := os.Args[1] - remoteName := os.Args[2] - - remoteURLBytes, err := ioutil.ReadAll(os.Stdin) - if err != nil { - log.Fatalf("error while reading remote URL: %v", err) - } - remoteURL := string(remoteURLBytes) - - err = addOrUpdate(repoPath, remoteName, remoteURL) - if err != nil { - log.Fatalf("error while setting remote: %v", err) - } -} - -//addOrUpdate adds, or updates if exits, the remote to repository -func addOrUpdate(repoPath string, name, url string) error { - if err := add(repoPath, name, url); err != nil { - return update(repoPath, name, url) - } - - return nil -} - -func add(repoPath string, name, url string) error { - git2repo, err := openGit2GoRepo(repoPath) - if err != nil { - return err - } - - _, err = git2repo.Remotes.Create(name, url) - return err -} - -func update(repoPath string, name, url string) error { - git2repo, err := openGit2GoRepo(repoPath) - if err != nil { - return err - } - - return git2repo.Remotes.SetUrl(name, url) -} - -func openGit2GoRepo(repoPath string) (*git.Repository, error) { - git2repo, err := git.OpenRepository(repoPath) - if err != nil { - return nil, err - } - - return git2repo, nil -} @@ -11,7 +11,6 @@ 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 v0.0.0-20190104134018-ecaeb7a21d47 github.com/prometheus/client_golang v1.0.0 github.com/prometheus/procfs v0.0.3 // indirect github.com/rubenv/sql-migrate v0.0.0-20191213152630-06338513c237 @@ -179,8 +179,6 @@ github.com/labstack/echo/v4 v4.1.10/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/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= |