Skip to content

Commit 7f9c2f1

Browse files
author
Robert Speicher
committed
Merge branch 'sh-show-all-refs' into 'master'
Support unhiding of all refs for Geo Nodes Closes gitlab-ee#2959 See merge request !150
2 parents 914f968 + d2185eb commit 7f9c2f1

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v5.5.0
2+
- Support unhiding of all references for Geo nodes
3+
14
v5.4.0
25
- Update Gitaly vendoring to use new RPC calls instead of old deprecated ones
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.4.0
1+
5.5.0

lib/gitlab_access_status.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
require 'json'
22

33
class GitAccessStatus
4-
attr_reader :message, :gl_repository, :repository_path, :gitaly
4+
attr_reader :message, :gl_repository, :repository_path, :gitaly, :geo_node
55

6-
def initialize(status, message, gl_repository, repository_path, gitaly)
6+
def initialize(status, message, gl_repository, repository_path, gitaly, geo_node = false)
77
@status = status
88
@message = message
99
@gl_repository = gl_repository
1010
@repository_path = repository_path
1111
@gitaly = gitaly
12+
@geo_node = geo_node
1213
end
1314

1415
def self.create_from_json(json)
1516
values = JSON.parse(json)
16-
self.new(values["status"], values["message"], values["gl_repository"], values["repository_path"], values["gitaly"])
17+
self.new(values["status"],
18+
values["message"],
19+
values["gl_repository"],
20+
values["repository_path"],
21+
values["gitaly"],
22+
values["geo_node"])
1723
end
1824

1925
def allowed?

lib/gitlab_net.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def check_access(cmd, gl_repository, repo, actor, changes, protocol, env: {})
3939
if resp.code == '200'
4040
GitAccessStatus.create_from_json(resp.body)
4141
else
42-
GitAccessStatus.new(false, 'API is not accessible', nil, nil)
42+
GitAccessStatus.new(false, 'API is not accessible', nil, nil, nil)
4343
end
4444
end
4545

lib/gitlab_shell.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class InvalidRepositoryPathError < StandardError; end
1717
API_COMMANDS = %w(2fa_recovery_codes)
1818
GL_PROTOCOL = 'ssh'.freeze
1919

20-
attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access
20+
attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :show_all_refs
2121
attr_reader :repo_path
2222

2323
def initialize(key_id)
@@ -100,6 +100,7 @@ def verify_access
100100
self.repo_path = status.repository_path
101101
@gl_repository = status.gl_repository
102102
@gitaly = status.gitaly
103+
@show_all_refs = status.geo_node
103104
end
104105

105106
def process_cmd(args)
@@ -159,6 +160,10 @@ def exec_cmd(*args)
159160
env['GITALY_TOKEN'] = @gitaly['token']
160161
end
161162

163+
# We have to use a negative transfer.hideRefs since this is the only way
164+
# to undo an already set parameter: https://www.spinics.net/lists/git/msg256772.html
165+
env['GIT_CONFIG_PARAMETERS'] = "'transfer.hideRefs=!refs'" if @show_all_refs
166+
162167
if git_trace_available?
163168
env.merge!({
164169
'GIT_TRACE' => @config.git_trace_log_file,

spec/gitlab_shell_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
end
2020
end
2121

22-
let(:gitaly_check_access) { GitAccessStatus.new(true, 'ok', gl_repository, repo_path, { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' })}
22+
let(:gitaly_check_access) { GitAccessStatus.new(true, 'ok', gl_repository, repo_path, { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' }) }
2323

2424
let(:api) do
2525
double(GitlabNet).tap do |api|
@@ -386,6 +386,20 @@
386386
shell.send :exec_cmd, [1, 2]
387387
end
388388

389+
context "when show_all_refs is enabled" do
390+
before { shell.show_all_refs = true }
391+
392+
it 'sets local git parameters' do
393+
expected_hash = hash_including(
394+
'GIT_CONFIG_PARAMETERS' => "'transfer.hideRefs=!refs'"
395+
)
396+
397+
Kernel.should_receive(:exec).with(expected_hash, [1, 2], exec_options).once
398+
399+
shell.send :exec_cmd, [1, 2]
400+
end
401+
end
402+
389403
context "when specifying a git_tracing log file" do
390404
let(:git_trace_log_file) { '/tmp/git_trace_performance.log' }
391405

0 commit comments

Comments
 (0)