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:
authorKim Carlbäcker <kim.carlbacker@gmail.com>2018-01-08 19:09:28 +0300
committerKim Carlbäcker <kim.carlbacker@gmail.com>2018-01-08 19:09:28 +0300
commit5832588a0cc93387125bbb0ed868ee069cc99cf5 (patch)
treed01cccc4a2509529b74a97ff4e55cffbd4a5c51c
parentccb26f0ece4776d306be0bdc19e7944efc18138f (diff)
parent66cb28723c21b0641654b513a8f3f38a4a44a8d8 (diff)
Merge branch 'mirror-refmaps-fix' into 'master'
Allow RemoteService.AddRemote to receive several mirror_refmaps See merge request gitlab-org/gitaly!513
-rw-r--r--CHANGELOG.md2
-rw-r--r--internal/service/remote/remotes_test.go69
-rw-r--r--ruby/Gemfile2
-rw-r--r--ruby/Gemfile.lock4
-rw-r--r--ruby/lib/gitaly_server/remote_service.rb22
-rw-r--r--vendor/gitlab.com/gitlab-org/gitaly-proto/go/VERSION2
-rw-r--r--vendor/gitlab.com/gitlab-org/gitaly-proto/go/remote.pb.go55
-rw-r--r--vendor/vendor.json10
8 files changed, 91 insertions, 75 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2cc4011bf..43c20b5b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
UNRELEASED
+- Allow RemoteService.AddRemote to receive several mirror_refmaps
+ https://gitlab.com/gitlab-org/gitaly/merge_requests/513
- Update vendored gitlab_git to 33cea50976
https://gitlab.com/gitlab-org/gitaly/merge_requests/518
- Update vendored gitlab_git to bce886b776a
diff --git a/internal/service/remote/remotes_test.go b/internal/service/remote/remotes_test.go
index fc8a92dfa..72fff4ad1 100644
--- a/internal/service/remote/remotes_test.go
+++ b/internal/service/remote/remotes_test.go
@@ -2,7 +2,6 @@ package remote
import (
"fmt"
- "strings"
"testing"
"google.golang.org/grpc/codes"
@@ -29,44 +28,51 @@ func TestSuccessfulAddRemote(t *testing.T) {
defer cancel()
testCases := []struct {
- description string
- remoteName string
- url string
- mirrorRefmap string
+ description string
+ remoteName string
+ url string
+ mirrorRefmaps []string
+ resolvedMirrorRefmaps []string
}{
{
- description: "creates a new remote",
- remoteName: "my-remote",
- url: "http://my-repo.git",
- mirrorRefmap: "",
+ description: "creates a new remote",
+ remoteName: "my-remote",
+ url: "http://my-repo.git",
},
{
- description: "if a remote with the same name exists, it updates it",
- remoteName: "my-remote",
- url: "johndoe@host:my-new-repo.git",
- mirrorRefmap: "",
+ description: "if a remote with the same name exists, it updates it",
+ remoteName: "my-remote",
+ url: "johndoe@host:my-new-repo.git",
},
{
- description: "sets the remote as mirror if mirror_refmap is present",
- remoteName: "my-mirror-remote",
- url: "http://my-mirror-repo.git",
- mirrorRefmap: "all_refs",
+ description: "doesn't set the remote as mirror if mirror_refmaps is not `present`",
+ remoteName: "my-non-mirror-remote",
+ url: "johndoe@host:my-new-repo.git",
+ mirrorRefmaps: []string{""},
},
{
- description: "doesn't set the remote as mirror if mirror_refmap is blank",
- remoteName: "my-non-mirror-remote",
- url: "http://my-non-mirror-repo.git",
- mirrorRefmap: " ",
+ description: "sets the remote as mirror if a mirror_refmap is present",
+ remoteName: "my-mirror-remote",
+ url: "http://my-mirror-repo.git",
+ mirrorRefmaps: []string{"all_refs"},
+ resolvedMirrorRefmaps: []string{"+refs/*:refs/*"},
+ },
+ {
+ description: "sets the remote as mirror with multiple mirror_refmaps",
+ remoteName: "my-other-mirror-remote",
+ url: "http://my-non-mirror-repo.git",
+ mirrorRefmaps: []string{"all_refs", "+refs/pull/*/head:refs/merge-requests/*/head"},
+ resolvedMirrorRefmaps: []string{"+refs/*:refs/*", "+refs/pull/*/head:refs/merge-requests/*/head"},
},
}
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
request := &pb.AddRemoteRequest{
- Repository: testRepo,
- Name: tc.remoteName,
- Url: tc.url,
- MirrorRefmap: tc.mirrorRefmap,
+ Repository: testRepo,
+ Name: tc.remoteName,
+ Url: tc.url,
+ MirrorRefmaps: tc.mirrorRefmaps,
}
_, err := client.AddRemote(ctx, request)
@@ -79,8 +85,10 @@ func TestSuccessfulAddRemote(t *testing.T) {
mirrorConfigRegexp := fmt.Sprintf("remote.%s", tc.remoteName)
mirrorConfig := string(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "config", "--get-regexp", mirrorConfigRegexp))
- if strings.TrimSpace(tc.mirrorRefmap) != "" {
- require.Contains(t, mirrorConfig, "fetch +refs/*:refs/*")
+ if len(tc.resolvedMirrorRefmaps) > 0 {
+ for _, resolvedMirrorRefmap := range tc.resolvedMirrorRefmaps {
+ require.Contains(t, mirrorConfig, resolvedMirrorRefmap)
+ }
require.Contains(t, mirrorConfig, "mirror true")
require.Contains(t, mirrorConfig, "prune true")
} else {
@@ -126,10 +134,9 @@ func TestFailedAddRemoteDueToValidation(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
request := &pb.AddRemoteRequest{
- Repository: testRepo,
- Name: tc.remoteName,
- Url: tc.url,
- MirrorRefmap: "",
+ Repository: testRepo,
+ Name: tc.remoteName,
+ Url: tc.url,
}
_, err := client.AddRemote(ctx, request)
diff --git a/ruby/Gemfile b/ruby/Gemfile
index 95bf6367f..cf2e35de4 100644
--- a/ruby/Gemfile
+++ b/ruby/Gemfile
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
gem 'github-linguist', '~> 4.7.0', require: 'linguist'
-gem 'gitaly-proto', '~> 0.62.0', require: 'gitaly'
+gem 'gitaly-proto', '~> 0.66.0', require: 'gitaly'
gem 'activesupport'
gem 'rdoc', '~> 4.2'
gem 'gollum-lib', '~> 4.2', require: false
diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock
index d8976893f..13742d903 100644
--- a/ruby/Gemfile.lock
+++ b/ruby/Gemfile.lock
@@ -17,7 +17,7 @@ GEM
multipart-post (>= 1.2, < 3)
gemojione (3.3.0)
json
- gitaly-proto (0.62.0)
+ gitaly-proto (0.66.0)
google-protobuf (~> 3.1)
grpc (~> 1.0)
github-linguist (4.7.6)
@@ -133,7 +133,7 @@ PLATFORMS
DEPENDENCIES
activesupport
- gitaly-proto (~> 0.62.0)
+ gitaly-proto (~> 0.66.0)
github-linguist (~> 4.7.0)
gitlab-styles (~> 2.0.0)
gollum-lib (~> 4.2)
diff --git a/ruby/lib/gitaly_server/remote_service.rb b/ruby/lib/gitaly_server/remote_service.rb
index 3b8837b36..6bbcbba58 100644
--- a/ruby/lib/gitaly_server/remote_service.rb
+++ b/ruby/lib/gitaly_server/remote_service.rb
@@ -6,7 +6,7 @@ module GitalyServer
bridge_exceptions do
repo = Gitlab::Git::Repository.from_gitaly(request.repository, call)
- mirror_refmap = parse_refmap(request.mirror_refmap)
+ mirror_refmap = parse_refmaps(request.mirror_refmaps)
repo.add_remote(request.name, request.url, mirror_refmap: mirror_refmap)
@@ -37,16 +37,22 @@ module GitalyServer
private
- def parse_refmap(refmap)
- return unless refmap && refmap.rstrip != ""
+ def parse_refmaps(refmaps)
+ return unless refmaps.present?
- refmap_spec = refmap.to_sym
+ parsed_refmaps = refmaps.map do |refmap|
+ next unless refmap.present?
- if Gitlab::Git::RepositoryMirroring::REFMAPS.has_key?(refmap_spec)
- refmap_spec
- else
- refmap
+ refmap_spec = refmap.to_sym
+
+ if Gitlab::Git::RepositoryMirroring::REFMAPS.has_key?(refmap_spec)
+ refmap_spec
+ else
+ refmap
+ end
end
+
+ parsed_refmaps.compact.presence
end
end
end
diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/VERSION b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/VERSION
index afed694ee..e40e4fc33 100644
--- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/VERSION
+++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/VERSION
@@ -1 +1 @@
-0.65.0
+0.66.0
diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/remote.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/remote.pb.go
index 82b268a5c..a303d844b 100644
--- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/remote.pb.go
+++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/remote.pb.go
@@ -21,8 +21,8 @@ type AddRemoteRequest struct {
Repository *Repository `protobuf:"bytes,1,opt,name=repository" json:"repository,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
Url string `protobuf:"bytes,3,opt,name=url" json:"url,omitempty"`
- // If set the remote is configured as a mirror with that mapping
- MirrorRefmap string `protobuf:"bytes,4,opt,name=mirror_refmap,json=mirrorRefmap" json:"mirror_refmap,omitempty"`
+ // If any, the remote is configured as a mirror with those mappings
+ MirrorRefmaps []string `protobuf:"bytes,5,rep,name=mirror_refmaps,json=mirrorRefmaps" json:"mirror_refmaps,omitempty"`
}
func (m *AddRemoteRequest) Reset() { *m = AddRemoteRequest{} }
@@ -51,11 +51,11 @@ func (m *AddRemoteRequest) GetUrl() string {
return ""
}
-func (m *AddRemoteRequest) GetMirrorRefmap() string {
+func (m *AddRemoteRequest) GetMirrorRefmaps() []string {
if m != nil {
- return m.MirrorRefmap
+ return m.MirrorRefmaps
}
- return ""
+ return nil
}
type AddRemoteResponse struct {
@@ -296,26 +296,27 @@ var _RemoteService_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("remote.proto", fileDescriptor9) }
var fileDescriptor9 = []byte{
- // 323 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x41, 0x4f, 0xf2, 0x40,
- 0x10, 0xfd, 0x0a, 0x84, 0x7c, 0x8c, 0x25, 0x81, 0xc1, 0x98, 0x5a, 0x3c, 0x90, 0x72, 0xe1, 0xd4,
- 0x03, 0xc6, 0xb3, 0xd1, 0x83, 0x89, 0xf1, 0xb6, 0x9e, 0x0d, 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61, 0xa5,
+ 0xa5, 0xdd, 0x57, 0x99, 0xbc, 0xd6, 0xa0, 0x67, 0xa8, 0x77, 0x48, 0xab, 0x60, 0x86, 0xec, 0x12,
+ 0x3a, 0x45, 0x00, 0xcc, 0xc9, 0xb5, 0xbf, 0x6f, 0x8f, 0x7b, 0x58, 0x51, 0xc9, 0xd2, 0xfa, 0xc7,
+ 0x1e, 0x60, 0x50, 0x61, 0x86, 0xf1, 0xbc, 0x67, 0xfb, 0xe3, 0xb9, 0xc7, 0x3b, 0x39, 0x85, 0xc2,
+ 0x2d, 0x74, 0xcb, 0x91, 0xb1, 0xe1, 0xe7, 0x23, 0xfd, 0xd8, 0x13, 0xf7, 0xa8, 0xba, 0x98, 0x0f,
+ 0x7b, 0x6c, 0xa5, 0x7f, 0xc9, 0xe9, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfa, 0xf4, 0xb8, 0x27,
+ 0x4b, 0x03, 0x00, 0x00,
}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 515b3a42f..e9bbc1d56 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -201,12 +201,12 @@
"revisionTime": "2017-01-30T11:31:45Z"
},
{
- "checksumSHA1": "ecgc6D1lbhf4iGqyqEl6lxjrNdw=",
+ "checksumSHA1": "YzdOHhUAADeS04hd34dzf6Sq4DA=",
"path": "gitlab.com/gitlab-org/gitaly-proto/go",
- "revision": "ddd55e057604ca7671fba73f251f8d5c325eba1e",
- "revisionTime": "2017-12-29T19:20:10Z",
- "version": "v0.65.0",
- "versionExact": "v0.65.0"
+ "revision": "d94b58bed008979a573f2176615309e7e3554786",
+ "revisionTime": "2018-01-04T20:34:42Z",
+ "version": "v0.66.0",
+ "versionExact": "v0.66.0"
},
{
"checksumSHA1": "nqWNlnMmVpt628zzvyo6Yv2CX5Q=",