Merge branch 'fix-wiki-clone-over-http' into 'master'

Fix cloning Wiki repositories via HTTP

Cloning a project Wiki over HTTP would end up cloning the main repository
since the .wiki extension was being stripped.

Closes #3106

See merge request !1676
This commit is contained in:
Robert Speicher 2015-10-23 11:31:01 +00:00
commit 2b51823017
3 changed files with 25 additions and 1 deletions

View file

@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 8.2.0 (unreleased)
- Fix cloning Wiki repositories via HTTP (Stan Hu)
- Improved performance of replacing references in comments
- Show last project commit to default branch on project home page
- Highlight comment based on anchor in URL

View file

@ -193,12 +193,19 @@ module Grack
end
def render_grack_auth_ok
repo_path =
if @request.path_info =~ /^([\w\.\/-]+)\.wiki\.git/
ProjectWiki.new(project).repository.path_to_repo
else
project.repository.path_to_repo
end
[
200,
{ "Content-Type" => "application/json" },
[JSON.dump({
'GL_ID' => Gitlab::ShellEnv.gl_id(@user),
'RepoPath' => project.repository.path_to_repo,
'RepoPath' => repo_path,
})]
]
end

View file

@ -50,6 +50,22 @@ describe Grack::Auth do
end
end
context "when the Wiki for a project exists" do
before do
@wiki = ProjectWiki.new(project)
env["PATH_INFO"] = "#{@wiki.repository.path_with_namespace}.git/info/refs"
project.update_attribute(:visibility_level, Project::PUBLIC)
end
it "responds with the right project" do
response = auth.call(env)
json_body = ActiveSupport::JSON.decode(response[2][0])
expect(response.first).to eq(200)
expect(json_body['RepoPath']).to include(@wiki.repository.path_with_namespace)
end
end
context "when the project exists" do
before do
env["PATH_INFO"] = project.path_with_namespace + ".git"