diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-26 11:19:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-26 11:19:09 +0300 |
commit | 5f13a13a07b066fe0b07bd0879369a1bd48838f2 (patch) | |
tree | 30634dac68d3ed9eae7452a63ec6660fb5f52c98 /config | |
parent | c20afb33b244921fd36244be6a02bdb94727f2c4 (diff) |
Add latest changes from gitlab-org/gitlab@16-0-stable-ee
Diffstat (limited to 'config')
-rw-r--r-- | config/routes/project.rb | 17 | ||||
-rw-r--r-- | config/routes/repository_deprecated.rb | 19 |
2 files changed, 35 insertions, 1 deletions
diff --git a/config/routes/project.rb b/config/routes/project.rb index 995c9879aa3..f296143dca8 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -632,8 +632,23 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do constraints: { id: /\d+/ } # rubocop: enable Cop/PutProjectRoutesUnderScope end - end + # All new routes should go under /-/ scope. + # Look for scope '-' at the top of the file. + + # Legacy routes. + # Introduced in 12.0. + # Should be removed with https://gitlab.com/gitlab-org/gitlab/issues/28848. + Gitlab::Routing.redirect_legacy_paths( + self, :mirror, :tags, :hooks, + :commits, :commit, :find_file, :files, :compare, + :cycle_analytics, :mattermost, :variables, :triggers, + :environments, :protected_environments, :error_tracking, :alert_management, + :serverless, :clusters, :audit_events, :wikis, :merge_requests, + :vulnerability_feedback, :security, :dependencies, :issues, + :pipelines, :pipeline_schedules, :runners, :snippets + ) + end # rubocop: disable Cop/PutProjectRoutesUnderScope resources( :projects, diff --git a/config/routes/repository_deprecated.rb b/config/routes/repository_deprecated.rb index 00206592fc8..32682000941 100644 --- a/config/routes/repository_deprecated.rb +++ b/config/routes/repository_deprecated.rb @@ -10,6 +10,21 @@ resource :repository, only: [:create] # Don't use format parameter as file extension (old 3.0.x behavior) # See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments scope format: false do + get '/refs/switch', + to: redirect('%{namespace_id}/%{project_id}/-/refs/switch') + + get '/refs/:id/logs_tree', + to: redirect('%{namespace_id}/%{project_id}/-/refs/%{id}/logs_tree'), + constraints: { id: Gitlab::PathRegex.git_reference_regex } + + get '/refs/:id/logs_tree/*path', + constraints: { id: /.*/, path: /[^\0]*/ }, + to: redirect { |params, _request| + path = params[:path] + path.gsub!('@', '-/') + Addressable::URI.escape("#{params[:namespace_id]}/#{params[:project_id]}/-/refs/#{params[:id]}/logs_tree/#{path}") + } + scope constraints: { id: /[^\0]+/ } do # Deprecated. Keep for compatibility. # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/118849 @@ -17,5 +32,9 @@ scope format: false do get '/blob/*id', to: 'blob#show', as: :deprecated_blob get '/raw/*id', to: 'raw#show', as: :deprecated_raw get '/blame/*id', to: 'blame#show', as: :deprecated_blame + + # Redirect those explicitly since `redirect_legacy_paths` conflicts with project new/edit actions + get '/new/*id', to: redirect('%{namespace_id}/%{project_id}/-/new/%{id}') + get '/edit/*id', to: redirect('%{namespace_id}/%{project_id}/-/edit/%{id}') end end |