diff options
Diffstat (limited to 'config/routes/repository.rb')
-rw-r--r-- | config/routes/repository.rb | 90 |
1 files changed, 21 insertions, 69 deletions
diff --git a/config/routes/repository.rb b/config/routes/repository.rb index 58de3d29bb0..854c6517cd5 100644 --- a/config/routes/repository.rb +++ b/config/routes/repository.rb @@ -1,84 +1,36 @@ # frozen_string_literal: true # All routing related to repository browsing +# +# NOTE: Add new routes to repository_scoped.rb instead (see +# https://docs.gitlab.com/ee/development/routing.html#project-routes). 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 - get '/compare/:from...:to', to: 'compare#show', as: 'compare', constraints: { from: /.+/, to: /.+/ } + get '/refs/switch', + to: redirect('%{namespace_id}/%{project_id}/-/refs/switch') - resources :compare, only: [:index, :create] do - collection do - get :diff_for_path - get :signatures - end - end - - resources :refs, only: [] do - collection do - get 'switch' - end + get '/refs/:id/logs_tree', + to: redirect('%{namespace_id}/%{project_id}/-/refs/%{id}/logs_tree'), + constraints: { id: Gitlab::PathRegex.git_reference_regex } - 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: { - id: /.*/, - path: /[^\0]*/ - } - end - end + 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 - scope controller: :blob do - get '/new/*id', action: :new, as: :new_blob - post '/create/*id', action: :create, as: :create_blob - get '/edit/*id', action: :edit, as: :edit_blob - put '/update/*id', action: :update, as: :update_blob - post '/preview/*id', action: :preview, as: :preview_blob - - scope path: '/blob/*id', as: :blob do - get :diff - get '/', action: :show - delete '/', action: :destroy - post '/', action: :create - put '/', action: :update - end - end - - get '/tree/*id', to: 'tree#show', as: :tree - get '/raw/*id', to: 'raw#show', as: :raw - get '/blame/*id', to: 'blame#show', as: :blame - - get '/commits', to: 'commits#commits_root', as: :commits_root - get '/commits/*id/signatures', to: 'commits#signatures', as: :signatures - get '/commits/*id', to: 'commits#show', as: :commits - - post '/create_dir/*id', to: 'tree#create_dir', as: :create_dir - - scope controller: :find_file do - get '/find_file/*id', action: :show, as: :find_file - - get '/files/*id', action: :list, as: :files - end + # 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 |