diff options
Diffstat (limited to 'config/routes')
-rw-r--r-- | config/routes/admin.rb | 20 | ||||
-rw-r--r-- | config/routes/project.rb | 25 | ||||
-rw-r--r-- | config/routes/repository.rb | 67 | ||||
-rw-r--r-- | config/routes/repository_deprecated.rb | 36 | ||||
-rw-r--r-- | config/routes/repository_scoped.rb | 41 | ||||
-rw-r--r-- | config/routes/user.rb | 1 |
6 files changed, 108 insertions, 82 deletions
diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 2ba00e3bf66..7bd24ac5f5b 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -95,6 +95,7 @@ namespace :admin do get :instance_review, to: 'instance_review#index' + resources :background_migrations, only: [:index] resource :health_check, controller: 'health_check', only: [:show] resource :background_jobs, controller: 'background_jobs', only: [:show] @@ -103,7 +104,6 @@ namespace :admin do resources :projects, only: [:index] - get '/instance_statistics', to: redirect('admin/usage_trends') resources :usage_trends, only: :index resource :dev_ops_report, controller: 'dev_ops_report', only: :show resources :cohorts, only: :index @@ -124,15 +124,6 @@ namespace :admin do end end - resource :appearances, only: [:show, :create, :update], path: 'appearance' do - member do - get :preview_sign_in - delete :logo - delete :header_logos - delete :favicon - end - end - resource :application_settings, only: :update do resources :services, only: [:index, :edit, :update] resources :integrations, only: [:edit, :update] do @@ -153,6 +144,15 @@ namespace :admin do get :status_create_self_monitoring_project delete :delete_self_monitoring_project get :status_delete_self_monitoring_project + + resource :appearances, only: [:show, :create, :update], path: 'appearance', module: 'application_settings' do + member do + get :preview_sign_in + delete :logo + delete :header_logos + delete :favicon + end + end end resources :plan_limits, only: :create diff --git a/config/routes/project.rb b/config/routes/project.rb index d62e2f1b2f2..641ca399547 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -50,7 +50,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - resources :infrastructure_registry, only: [:index], module: :packages + resources :infrastructure_registry, only: [:index, :show], module: :packages resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do collection do @@ -273,6 +273,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resources :value_streams, only: [:index] do resources :stages, only: [:index] end + resource :summary, controller: :summary, only: :show end end @@ -385,7 +386,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do # The wiki and repository routing contains wildcard characters so # its preferable to keep it below all other project routes - draw :repository_scoped draw :repository draw :wiki @@ -404,7 +404,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resource :feature_flags_client, only: [] do post :reset_token end - resources :feature_flags_user_lists, param: :iid, only: [:new, :edit, :show] + resources :feature_flags_user_lists, param: :iid, only: [:index, :new, :edit, :show] get '/schema/:branch/*filename', to: 'web_ide_schemas#show', @@ -566,15 +566,15 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do # Deprecated unscoped routing. scope as: 'deprecated' do # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 - draw :repository + draw :repository_deprecated - # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/29572 - resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do # rubocop: disable Cop/PutProjectRoutesUnderScope - member do - get :raw # rubocop:todo Cop/PutProjectRoutesUnderScope - post :mark_as_spam # rubocop:todo Cop/PutProjectRoutesUnderScope - end - end + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/223719 + # rubocop: disable Cop/PutProjectRoutesUnderScope + get '/snippets/:id/raw', + to: 'snippets#raw', + format: false, + constraints: { id: /\d+/ } + # rubocop: enable Cop/PutProjectRoutesUnderScope end # All new routes should go under /-/ scope. @@ -584,12 +584,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do # 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, :tracing, :serverless, :clusters, :audit_events, :wikis, :merge_requests, :vulnerability_feedback, :security, :dependencies, :issues, - :pipelines, :pipeline_schedules) + :pipelines, :pipeline_schedules, :snippets) end # rubocop: disable Cop/PutProjectRoutesUnderScope diff --git a/config/routes/repository.rb b/config/routes/repository.rb index 58de3d29bb0..d2be18c62f9 100644 --- a/config/routes/repository.rb +++ b/config/routes/repository.rb @@ -1,24 +1,8 @@ # frozen_string_literal: true # All routing related to repository browsing +# that is already under /-/ scope only -resource :repository, only: [:create] - -resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do - member do - get :branches - get :pipelines - post :revert - post :cherry_pick - get :diff_for_path - get :diff_files - get :merge_requests - end -end - -# NOTE: Add new routes to repository_scoped.rb instead (see -# https://docs.gitlab.com/ee/development/routing.html#project-routes). -# # 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 @@ -39,6 +23,7 @@ scope format: false do member do # tree viewer logs get 'logs_tree', constraints: { id: Gitlab::PathRegex.git_reference_regex } + # Directories with leading dots erroneously get rejected if git # ref regex used in constraints. Regex verification now done in controller. get 'logs_tree/*path', action: :logs_tree, as: :logs_file, format: false, constraints: { @@ -48,6 +33,39 @@ scope format: false do end end + scope constraints: { id: Gitlab::PathRegex.git_reference_regex } do + resources :network, only: [:show] + + resources :graphs, only: [:show] do + member do + get :charts + get :commits + get :ci + get :languages + end + end + + get '/branches/:state', to: 'branches#index', as: :branches_filtered, constraints: { state: /active|stale|all/ } + resources :branches, only: [:index, :new, :create, :destroy] do + get :diverging_commit_counts, on: :collection + end + + delete :merged_branches, controller: 'branches', action: :destroy_all_merged + resources :tags, only: [:index, :show, :new, :create, :destroy] do + resource :release, controller: 'tags/releases', only: [:edit, :update] + end + + resources :protected_branches, only: [:index, :show, :create, :update, :destroy, :patch], constraints: { id: Gitlab::PathRegex.git_reference_regex } + resources :protected_tags, only: [:index, :show, :create, :update, :destroy] + + scope constraints: { id: /[^\0]+?/ } do + scope controller: :static_site_editor do + get '/sse/:id(/*vueroute)', action: :show, as: :show_sse + get '/sse', as: :root_sse, action: :index + end + end + end + scope constraints: { id: /[^\0]+/ } do scope controller: :blob do get '/new/*id', action: :new, as: :new_blob @@ -77,8 +95,21 @@ scope format: false do scope controller: :find_file do get '/find_file/*id', action: :show, as: :find_file - get '/files/*id', action: :list, as: :files end end end + +resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do + member do + get :branches + get :pipelines + post :revert + post :cherry_pick + get :diff_for_path + get :diff_files + get :merge_requests + end +end + +resource :repository, only: [:create] diff --git a/config/routes/repository_deprecated.rb b/config/routes/repository_deprecated.rb new file mode 100644 index 00000000000..e611b4f665b --- /dev/null +++ b/config/routes/repository_deprecated.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +# Repository routes without /-/ scope. +# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/28848. +# Do not add new routes here. Add new routes to repository.rb instead +# (see https://docs.gitlab.com/ee/development/routing.html#project-routes). + +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', + to: redirect('%{namespace_id}/%{project_id}/-/refs/%{id}/logs_tree/%{path}'), + constraints: { id: /.*/, path: /[^\0]*/ } + + scope constraints: { id: /[^\0]+/ } do + # Deprecated. Keep for compatibility. + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/118849 + get '/tree/*id', to: 'tree#show', as: :deprecated_tree + 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 diff --git a/config/routes/repository_scoped.rb b/config/routes/repository_scoped.rb deleted file mode 100644 index 7fabf3ff895..00000000000 --- a/config/routes/repository_scoped.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -# All routing related to repository browsing -# that is already under /-/ scope only - -# 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 - scope constraints: { id: Gitlab::PathRegex.git_reference_regex } do - resources :network, only: [:show] - - resources :graphs, only: [:show] do - member do - get :charts - get :commits - get :ci - get :languages - end - end - - get '/branches/:state', to: 'branches#index', as: :branches_filtered, constraints: { state: /active|stale|all/ } - resources :branches, only: [:index, :new, :create, :destroy] do - get :diverging_commit_counts, on: :collection - end - - delete :merged_branches, controller: 'branches', action: :destroy_all_merged - resources :tags, only: [:index, :show, :new, :create, :destroy] do - resource :release, controller: 'tags/releases', only: [:edit, :update] - end - - resources :protected_branches, only: [:index, :show, :create, :update, :destroy, :patch], constraints: { id: Gitlab::PathRegex.git_reference_regex } - resources :protected_tags, only: [:index, :show, :create, :update, :destroy] - - scope constraints: { id: /[^\0]+?/ } do - scope controller: :static_site_editor do - get '/sse/:id(/*vueroute)', action: :show, as: :show_sse - get '/sse', as: :root_sse, action: :index - end - end - end -end diff --git a/config/routes/user.rb b/config/routes/user.rb index 41319b6d730..5f746eb6670 100644 --- a/config/routes/user.rb +++ b/config/routes/user.rb @@ -49,7 +49,6 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d get :followers get :following get :exists - get :suggests get :activity post :follow post :unfollow |