From 712183453553b2e18f250ea26ebe121a13c0e5c9 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 23 Oct 2015 11:31:01 +0000 Subject: 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 --- CHANGELOG | 11 +++++++++++ lib/gitlab/backend/grack_auth.rb | 9 ++++++++- spec/lib/gitlab/backend/grack_auth_spec.rb | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c3a76b1fc15..440ee7c3558 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,16 @@ 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 + - Adds ability to remove the forked relationship from project settings screen. (Han Loong Liauw) + - Improved performance of sorting milestone issues + - Allow users to select the Files view as default project view (Cristian Bica) + - Show "Empty Repository Page" for repository without branches (Artem V. Navrotskiy) + - Fix: Inability to reply to code comments in the MR view, if the MR comes from a fork + v 8.1.0 - Ensure MySQL CI limits DB migrations occur after the fields have been created (Stan Hu) - Redirect to a default path if HTTP_REFERER is not set (Stan Hu) diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index 6830a916bcb..85a2d1a93a7 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -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 diff --git a/spec/lib/gitlab/backend/grack_auth_spec.rb b/spec/lib/gitlab/backend/grack_auth_spec.rb index 37c527221a0..dfa0e10318a 100644 --- a/spec/lib/gitlab/backend/grack_auth_spec.rb +++ b/spec/lib/gitlab/backend/grack_auth_spec.rb @@ -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" -- cgit v1.2.3