summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-07-25 15:16:54 +0000
committerRobert Speicher <robert@gitlab.com>2017-07-25 15:16:54 +0000
commit7f9c2f18fb7c6788a3d717c5a727de27616e8fbc (patch)
treed852e1c3907325512d837b43ec6845f9104afc56
parent914f968523779972e74f5a12a9e6b668c184c898 (diff)
parentd2185eba130c95573534394ae4c1000c8bb8ab27 (diff)
downloadgitlab-shell-7f9c2f18fb7c6788a3d717c5a727de27616e8fbc.tar.gz
Merge branch 'sh-show-all-refs' into 'master'
Support unhiding of all refs for Geo Nodes Closes gitlab-ee#2959 See merge request !150
-rw-r--r--CHANGELOG3
-rw-r--r--VERSION2
-rw-r--r--lib/gitlab_access_status.rb12
-rw-r--r--lib/gitlab_net.rb2
-rw-r--r--lib/gitlab_shell.rb7
-rw-r--r--spec/gitlab_shell_spec.rb16
6 files changed, 35 insertions, 7 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 6d0b3cf..9c67edc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v5.5.0
+ - Support unhiding of all references for Geo nodes
+
v5.4.0
- Update Gitaly vendoring to use new RPC calls instead of old deprecated ones
diff --git a/VERSION b/VERSION
index 8a30e8f..d50359d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5.4.0
+5.5.0
diff --git a/lib/gitlab_access_status.rb b/lib/gitlab_access_status.rb
index a6a274c..988ff7a 100644
--- a/lib/gitlab_access_status.rb
+++ b/lib/gitlab_access_status.rb
@@ -1,19 +1,25 @@
require 'json'
class GitAccessStatus
- attr_reader :message, :gl_repository, :repository_path, :gitaly
+ attr_reader :message, :gl_repository, :repository_path, :gitaly, :geo_node
- def initialize(status, message, gl_repository, repository_path, gitaly)
+ def initialize(status, message, gl_repository, repository_path, gitaly, geo_node = false)
@status = status
@message = message
@gl_repository = gl_repository
@repository_path = repository_path
@gitaly = gitaly
+ @geo_node = geo_node
end
def self.create_from_json(json)
values = JSON.parse(json)
- self.new(values["status"], values["message"], values["gl_repository"], values["repository_path"], values["gitaly"])
+ self.new(values["status"],
+ values["message"],
+ values["gl_repository"],
+ values["repository_path"],
+ values["gitaly"],
+ values["geo_node"])
end
def allowed?
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 4c938b1..3acebea 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -39,7 +39,7 @@ class GitlabNet
if resp.code == '200'
GitAccessStatus.create_from_json(resp.body)
else
- GitAccessStatus.new(false, 'API is not accessible', nil, nil)
+ GitAccessStatus.new(false, 'API is not accessible', nil, nil, nil)
end
end
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb
index 262f9f7..e3025ef 100644
--- a/lib/gitlab_shell.rb
+++ b/lib/gitlab_shell.rb
@@ -17,7 +17,7 @@ class GitlabShell
API_COMMANDS = %w(2fa_recovery_codes)
GL_PROTOCOL = 'ssh'.freeze
- attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access
+ attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :show_all_refs
attr_reader :repo_path
def initialize(key_id)
@@ -100,6 +100,7 @@ class GitlabShell
self.repo_path = status.repository_path
@gl_repository = status.gl_repository
@gitaly = status.gitaly
+ @show_all_refs = status.geo_node
end
def process_cmd(args)
@@ -159,6 +160,10 @@ class GitlabShell
env['GITALY_TOKEN'] = @gitaly['token']
end
+ # We have to use a negative transfer.hideRefs since this is the only way
+ # to undo an already set parameter: https://www.spinics.net/lists/git/msg256772.html
+ env['GIT_CONFIG_PARAMETERS'] = "'transfer.hideRefs=!refs'" if @show_all_refs
+
if git_trace_available?
env.merge!({
'GIT_TRACE' => @config.git_trace_log_file,
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb
index 29093ac..87389b4 100644
--- a/spec/gitlab_shell_spec.rb
+++ b/spec/gitlab_shell_spec.rb
@@ -19,7 +19,7 @@ describe GitlabShell do
end
end
- let(:gitaly_check_access) { GitAccessStatus.new(true, 'ok', gl_repository, repo_path, { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' })}
+ let(:gitaly_check_access) { GitAccessStatus.new(true, 'ok', gl_repository, repo_path, { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' }) }
let(:api) do
double(GitlabNet).tap do |api|
@@ -386,6 +386,20 @@ describe GitlabShell do
shell.send :exec_cmd, [1, 2]
end
+ context "when show_all_refs is enabled" do
+ before { shell.show_all_refs = true }
+
+ it 'sets local git parameters' do
+ expected_hash = hash_including(
+ 'GIT_CONFIG_PARAMETERS' => "'transfer.hideRefs=!refs'"
+ )
+
+ Kernel.should_receive(:exec).with(expected_hash, [1, 2], exec_options).once
+
+ shell.send :exec_cmd, [1, 2]
+ end
+ end
+
context "when specifying a git_tracing log file" do
let(:git_trace_log_file) { '/tmp/git_trace_performance.log' }