summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-06-08 11:34:24 +0100
committerSean McGivern <sean@gitlab.com>2016-06-08 20:55:34 +0100
commitcba32b71bd27b747f5a667ec6ba11ff5e21362ef (patch)
tree85ecf4e0e6915edc290526d9d4978941d4d5b975
parent915ad255cdc7afa9a44ba24eed62f28184e81836 (diff)
downloadgitlab-ce-cba32b71bd27b747f5a667ec6ba11ff5e21362ef.tar.gz
Allow clones from /namespace/project
Redirect /namespace/project/info/refs to /namespace/project.git/info/refs, so `git clone` works on either namespace/project.git or namespace/project.
-rw-r--r--CHANGELOG1
-rw-r--r--config/routes.rb17
2 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 5136756079d..419ea3d1b50 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,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 240dcc74b06..f1a43cbbd26 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