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:
authorNick Thomas <nick@gitlab.com>2020-05-19 21:20:00 +0300
committerNick Thomas <nick@gitlab.com>2020-05-19 21:56:07 +0300
commit4bc2b125a632031688f399d456d5a5dcd6e707f5 (patch)
tree20e044ea1d42d913a3f0147265b30da68e007951
parent1e9db85af70799ff697df32d1ed4ea3ef5764378 (diff)
Pass SSH environment through to git ls-remote command for remote branches
Without this, for an SSH remote, the known_hosts and SSH key will not be available, and the `ls-remote` command will fail. It's somewhat clunky though, perhaps there's a better way to do this?
-rw-r--r--ruby/lib/gitlab/git/remote_mirror.rb8
-rw-r--r--ruby/lib/gitlab/git/repository_mirroring.rb4
-rw-r--r--ruby/spec/lib/gitlab/git/remote_mirror_spec.rb4
3 files changed, 8 insertions, 8 deletions
diff --git a/ruby/lib/gitlab/git/remote_mirror.rb b/ruby/lib/gitlab/git/remote_mirror.rb
index 8b5d5d4d3..45a1936a1 100644
--- a/ruby/lib/gitlab/git/remote_mirror.rb
+++ b/ruby/lib/gitlab/git/remote_mirror.rb
@@ -20,9 +20,9 @@ module Gitlab
def update
ssh_auth.setup do |env|
- updated_branches = changed_refs(local_branches, remote_branches)
+ updated_branches = changed_refs(local_branches, remote_branches(env: env))
push_refs(default_branch_first(updated_branches.keys), env: env)
- delete_refs(local_branches, remote_branches, env: env)
+ delete_refs(local_branches, remote_branches(env: env), env: env)
local_tags = refs_obj(repository.tags)
remote_tags = refs_obj(repository.remote_tags(remote_name, env: env))
@@ -48,9 +48,9 @@ module Gitlab
)
end
- def remote_branches
+ def remote_branches(env:)
@remote_branches ||= refs_obj(
- repository.remote_branches(remote_name),
+ repository.remote_branches(remote_name, env: env),
match_refs: true
)
end
diff --git a/ruby/lib/gitlab/git/repository_mirroring.rb b/ruby/lib/gitlab/git/repository_mirroring.rb
index 129bab9c1..0e7f9f15b 100644
--- a/ruby/lib/gitlab/git/repository_mirroring.rb
+++ b/ruby/lib/gitlab/git/repository_mirroring.rb
@@ -12,7 +12,7 @@ module Gitlab
tags: '+refs/tags/*:refs/tags/*'
}.freeze
- def remote_branches(remote_name)
+ def remote_branches(remote_name, env:)
branches = []
rugged.references.each("refs/remotes/#{remote_name}/*").map do |ref|
@@ -30,7 +30,7 @@ module Gitlab
#
# See https://gitlab.com/gitlab-org/gitaly/-/issues/2670
if feature_enabled?(:remote_branches_ls_remote)
- ls_remote_branches = experimental_remote_branches(remote_name)
+ ls_remote_branches = experimental_remote_branches(remote_name, env: env)
control_refs = branches.collect(&:name)
experiment_refs = ls_remote_branches.collect(&:name)
diff --git a/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb b/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb
index e4611bce0..1821a7aa9 100644
--- a/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb
+++ b/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb
@@ -49,7 +49,7 @@ describe Gitlab::Git::RemoteMirror do
expect(repository).to receive(:local_branches).and_return([ref('master'), ref('11-5-stable'), ref('unprotected')])
expect(repository).to receive(:remote_branches)
- .with(ref_name)
+ .with(ref_name, env: env)
.and_return([ref('master'), ref('obsolete-branch')])
expect(repository).to receive(:tags).and_return([tag('v1.0.0'), tag('new-tag')])
@@ -87,7 +87,7 @@ describe Gitlab::Git::RemoteMirror do
expect(repository).to receive(:local_branches).and_return([ref('master'), ref('new-branch')])
expect(repository).to receive(:remote_branches)
- .with(ref_name)
+ .with(ref_name, env: env)
.and_return([ref('master'), ref('obsolete-branch')])
expect(repository).to receive(:tags).and_return([tag('v1.0.0'), tag('new-tag')])