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 14:04:56 +0100
commit027615f3a6bd82ae4fee7100b84637f6067f585f (patch)
tree761f0491290831e8981da7c22eea4bee6d23e274
parent915ad255cdc7afa9a44ba24eed62f28184e81836 (diff)
downloadgitlab-ce-13840-allow-clones-from-http-url-s-without-appending-git.tar.gz
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..d2b14aa1203 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(/^service=git-(upload|receive)-pack$/)
+ 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