Commit 08d2cb1c authored by Douwe Maan's avatar Douwe Maan

Merge branch 'bvl-fix-git-pull-repo-when-project-does-not-exist' into 'master'

Fall back to project repository type by default

Closes #60007

See merge request gitlab-org/gitlab-ce!27003
parents 934dabaf 2fdda744
...@@ -98,10 +98,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController ...@@ -98,10 +98,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
def repo_type def repo_type
parse_repo_path unless defined?(@repo_type) parse_repo_path unless defined?(@repo_type)
# When there a project did not exist, the parsed repo_type would be empty.
# In that case, we want to continue with a regular project repository. As we @repo_type
# could create the project if the user pushing is allowed to do so.
@repo_type || Gitlab::GlRepository::PROJECT
end end
def handle_basic_authentication(login, password) def handle_basic_authentication(login, password)
......
...@@ -35,5 +35,9 @@ module Gitlab ...@@ -35,5 +35,9 @@ module Gitlab
[project, type] [project, type]
end end
def self.default_type
PROJECT
end
end end
end end
...@@ -24,7 +24,10 @@ module Gitlab ...@@ -24,7 +24,10 @@ module Gitlab
return [project, type, redirected_path] if project return [project, type, redirected_path] if project
end end
nil # When a project did not exist, the parsed repo_type would be empty.
# In that case, we want to continue with a regular project repository. As we
# could create the project if the user pushing is allowed to do so.
[nil, Gitlab::GlRepository.default_type, nil]
end end
def self.find_project(project_path) def self.find_project(project_path)
......
...@@ -44,8 +44,10 @@ describe ::Gitlab::RepoPath do ...@@ -44,8 +44,10 @@ describe ::Gitlab::RepoPath do
end end
end end
it "returns nil for non existent paths" do it "returns the default type for non existent paths" do
expect(described_class.parse("path/non-existent.git")).to eq(nil) _project, type, _redirected = described_class.parse("path/non-existent.git")
expect(type).to eq(Gitlab::GlRepository.default_type)
end end
end end
......
...@@ -644,6 +644,22 @@ describe API::Internal do ...@@ -644,6 +644,22 @@ describe API::Internal do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
end end
it 'returns a 200 response when using a project path that does not exist' do
post(
api("/internal/allowed"),
params: {
key_id: key.id,
project: 'project/does-not-exist.git',
action: 'git-upload-pack',
secret_token: secret_token,
protocol: 'ssh'
}
)
expect(response).to have_gitlab_http_status(404)
expect(json_response["status"]).to be_falsey
end
end end
context 'user does not exist' do context 'user does not exist' do
......
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