summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-06-08 20:48:24 +0000
committerRobert Speicher <robert@gitlab.com>2016-06-08 20:48:24 +0000
commitfe75d163ab7d04419de97b43c0cd95b5929d57cb (patch)
tree9d834a1e423a690c06f68466471cc1f91566b529
parentd74e93ce46f1ca3f23e5011138f77ad64e316d11 (diff)
parentcba32b71bd27b747f5a667ec6ba11ff5e21362ef (diff)
downloadgitlab-ce-fe75d163ab7d04419de97b43c0cd95b5929d57cb.tar.gz
Merge branch '13840-allow-clones-from-http-url-s-without-appending-git' into 'master'
Allow clones from /namespace/project Allow `git clone https://host/namespace/project` to work, in addition to `git clone https://host/namespace/project.git` Closes #13840. See merge request !4530
-rw-r--r--CHANGELOG1
-rw-r--r--config/routes.rb17
2 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3ae881da362..b697aa5825e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@ v 8.9.0 (unreleased)
- Redesign navigation for project pages
- Fix groups API to list only user's accessible projects
- Redesign account and email confirmation emails
+ - `git clone https://host/namespace/project` now works, in addition to using the `.git` suffix
- Bump nokogiri to 1.6.8
- Use gitlab-shell v3.0.0
- Use Knapsack to evenly distribute tests across multiple nodes
diff --git a/config/routes.rb b/config/routes.rb
index 49d329028d1..417289829db 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -441,6 +441,23 @@ Rails.application.routes.draw do
resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }, except:
[:new, :create, :index], path: "/") do
+
+ # Allow /info/refs, /info/refs?service=git-upload-pack, and
+ # /info/refs?service=git-receive-pack, but nothing else.
+ #
+ git_http_handshake = lambda do |request|
+ request.query_string.blank? ||
+ request.query_string.match(/\Aservice=git-(upload|receive)-pack\z/)
+ end
+
+ ref_redirect = redirect do |params, request|
+ path = "#{params[:namespace_id]}/#{params[:project_id]}.git/info/refs"
+ path << "?#{request.query_string}" unless request.query_string.blank?
+ path
+ end
+
+ get '/info/refs', constraints: git_http_handshake, to: ref_redirect
+
member do
put :transfer
delete :remove_fork