debian-mirror-gitlab/config/routes/git_http.rb

66 lines
2.3 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2021-02-22 17:27:13 +05:30
scope(path: '*repository_path', format: false) do
constraints(repository_path: Gitlab::PathRegex.repository_git_route_regex) do
2020-03-13 15:44:24 +05:30
scope(module: :repositories) do
2021-02-22 17:27:13 +05:30
# Git HTTP API
scope(controller: :git_http) do
get '/info/refs', action: :info_refs
post '/git-upload-pack', action: :git_upload_pack
post '/git-receive-pack', action: :git_receive_pack
end
# NOTE: LFS routes are exposed on all repository types, but we still check for
# LFS availability on the repository container in LfsRequest#lfs_check_access!
# Git LFS API (metadata)
scope(path: 'info/lfs/objects', controller: :lfs_api) do
post :batch
post '/', action: :deprecated
get '/*oid', action: :deprecated
end
scope(path: 'info/lfs') do
resources :lfs_locks, controller: :lfs_locks_api, path: 'locks' do
post :unlock, on: :member
post :verify, on: :collection
end
end
# GitLab LFS object storage
scope(path: 'gitlab-lfs/objects/*oid', controller: :lfs_storage, constraints: { oid: /[a-f0-9]{64}/ }) do
get '/', action: :download
constraints(size: /[0-9]+/) do
put '/*size/authorize', action: :upload_authorize
put '/*size', action: :upload_finalize
end
end
2017-08-17 22:00:37 +05:30
end
end
2019-10-12 21:52:04 +05:30
# Redirect /group/project.wiki.git to the project wiki
2021-02-22 17:27:13 +05:30
constraints(repository_path: Gitlab::PathRegex.repository_wiki_git_route_regex) do
2019-10-12 21:52:04 +05:30
wiki_redirect = redirect do |params, request|
2021-02-22 17:27:13 +05:30
container_path = params[:repository_path].delete_suffix('.wiki.git')
path = File.join(container_path, '-', 'wikis')
2021-03-11 19:13:27 +05:30
path += "?#{request.query_string}" unless request.query_string.blank?
2019-10-12 21:52:04 +05:30
path
end
get '/', to: wiki_redirect
end
2017-08-17 22:00:37 +05:30
# Redirect /group/project/info/refs to /group/project.git/info/refs
2021-02-22 17:27:13 +05:30
# This allows cloning a repository without the trailing `.git`
constraints(repository_path: Gitlab::PathRegex.repository_route_regex) do
2017-08-17 22:00:37 +05:30
ref_redirect = redirect do |params, request|
2021-02-22 17:27:13 +05:30
path = "#{params[:repository_path]}.git/info/refs"
2021-03-11 19:13:27 +05:30
path += "?#{request.query_string}" unless request.query_string.blank?
2017-08-17 22:00:37 +05:30
path
end
2021-02-22 17:27:13 +05:30
get '/info/refs', constraints: ::Constraints::RepositoryRedirectUrlConstrainer.new, to: ref_redirect
2017-08-17 22:00:37 +05:30
end
end