Commit 25e7761f authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-fix-git-upload-pack' into 'master'

Fix SSH support for Git for Windows v2.14

Closes gitlab-ce#36028

See merge request !159
parents 20896b64 5687bd24
v5.8.0
- Fix SSH support for Git for Windows v2.14
v5.7.0 v5.7.0
- Support unhiding of all refs via Gitaly - Support unhiding of all refs via Gitaly
......
...@@ -38,7 +38,7 @@ class GitlabShell ...@@ -38,7 +38,7 @@ class GitlabShell
end end
args = Shellwords.shellwords(origin_cmd) args = Shellwords.shellwords(origin_cmd)
parse_cmd(args) args = parse_cmd(args)
if GIT_COMMANDS.include?(args.first) if GIT_COMMANDS.include?(args.first)
GitlabMetrics.measure('verify-access') { verify_access } GitlabMetrics.measure('verify-access') { verify_access }
...@@ -70,10 +70,17 @@ class GitlabShell ...@@ -70,10 +70,17 @@ class GitlabShell
protected protected
def parse_cmd(args) def parse_cmd(args)
@command = args.first # Handle Git for Windows 2.14 using "git upload-pack" instead of git-upload-pack
if args.length == 3 && args.first == 'git'
@command = "git-#{args[1]}"
args = [@command, args.last]
else
@command = args.first
end
@git_access = @command @git_access = @command
return if API_COMMANDS.include?(@command) return args if API_COMMANDS.include?(@command)
raise DisallowedCommandError unless GIT_COMMANDS.include?(@command) raise DisallowedCommandError unless GIT_COMMANDS.include?(@command)
...@@ -93,6 +100,8 @@ class GitlabShell ...@@ -93,6 +100,8 @@ class GitlabShell
raise DisallowedCommandError unless args.count == 2 raise DisallowedCommandError unless args.count == 2
@repo_name = args.last @repo_name = args.last
end end
args
end end
def verify_access def verify_access
......
...@@ -132,8 +132,8 @@ describe GitlabShell do ...@@ -132,8 +132,8 @@ describe GitlabShell do
describe :exec do describe :exec do
let(:gitaly_message) { JSON.dump({ 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default' }, 'gl_repository' => gl_repository , 'gl_id' => key_id}) } let(:gitaly_message) { JSON.dump({ 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default' }, 'gl_repository' => gl_repository , 'gl_id' => key_id}) }
context 'git-upload-pack' do shared_examples_for 'upload-pack' do |command|
let(:ssh_cmd) { "git-upload-pack gitlab-ci.git" } let(:ssh_cmd) { "#{command} gitlab-ci.git" }
after { subject.exec(ssh_cmd) } after { subject.exec(ssh_cmd) }
it "should process the command" do it "should process the command" do
...@@ -157,6 +157,14 @@ describe GitlabShell do ...@@ -157,6 +157,14 @@ describe GitlabShell do
end end
end end
context 'git-upload-pack' do
it_behaves_like 'upload-pack', 'git-upload-pack'
end
context 'git upload-pack' do
it_behaves_like 'upload-pack', 'git upload-pack'
end
context 'gitaly-upload-pack with GeoNode' do context 'gitaly-upload-pack with GeoNode' do
let(:ssh_cmd) { "git-upload-pack gitlab-ci.git" } let(:ssh_cmd) { "git-upload-pack gitlab-ci.git" }
let(:gitaly_check_access_with_geo) { GitAccessStatus.new(true, 'ok', gl_repository, repo_path, { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' }, true) } let(:gitaly_check_access_with_geo) { GitAccessStatus.new(true, 'ok', gl_repository, repo_path, { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' }, true) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment