diff options
Diffstat (limited to 'config/routes/project.rb')
-rw-r--r-- | config/routes/project.rb | 103 |
1 files changed, 69 insertions, 34 deletions
diff --git a/config/routes/project.rb b/config/routes/project.rb index 085f5a24e2e..5aac44fce10 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -1,13 +1,29 @@ require 'constraints/project_url_constrainer' +require 'gitlab/routes/legacy_builds' resources :projects, only: [:index, :new, :create] draw :git_http constraints(ProjectUrlConstrainer.new) do - scope(path: '*namespace_id', as: :namespace) do + # If the route has a wildcard segment, the segment has a regex constraint, + # the segment is potentially followed by _another_ wildcard segment, and + # the `format` option is not set to false, we need to specify that + # regex constraint _outside_ of `constraints: {}`. + # + # Otherwise, Rails will overwrite the constraint with `/.+?/`, + # which breaks some of our wildcard routes like `/blob/*id` + # and `/tree/*id` that depend on the negative lookahead inside + # `Gitlab::PathRegex.full_namespace_route_regex`, which helps the router + # determine whether a certain path segment is part of `*namespace_id`, + # `:project_id`, or `*id`. + # + # See https://github.com/rails/rails/blob/v4.2.8/actionpack/lib/action_dispatch/routing/mapper.rb#L155 + scope(path: '*namespace_id', + as: :namespace, + namespace_id: Gitlab::PathRegex.full_namespace_route_regex) do scope(path: ':project_id', - constraints: { project_id: Gitlab::Regex.project_route_regex }, + constraints: { project_id: Gitlab::PathRegex.project_route_regex }, module: :projects, as: :project) do @@ -74,11 +90,9 @@ constraints(ProjectUrlConstrainer.new) do get :conflicts get :conflict_for_path get :pipelines - get :merge_check + get :commit_change_content post :merge - get :merge_widget_refresh post :cancel_merge_when_pipeline_succeeds - get :ci_status get :pipeline_status get :ci_environments_status post :toggle_subscription @@ -123,10 +137,17 @@ constraints(ProjectUrlConstrainer.new) do post :cancel post :retry get :builds + get :failures get :status end end + resources :pipeline_schedules, except: [:show] do + member do + post :take_ownership + end + end + resources :environments, except: [:destroy] do member do post :stop @@ -139,7 +160,11 @@ constraints(ProjectUrlConstrainer.new) do get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ } end - resources :deployments, only: [:index] + resources :deployments, only: [:index] do + member do + get :metrics + end + end end resource :cycle_analytics, only: [:show] @@ -156,42 +181,52 @@ constraints(ProjectUrlConstrainer.new) do end end - resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do - collection do - post :cancel_all - - resources :artifacts, only: [] do - collection do - get :latest_succeeded, - path: '*ref_name_and_path', - format: false + scope '-' do + resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do + collection do + post :cancel_all + + resources :artifacts, only: [] do + collection do + get :latest_succeeded, + path: '*ref_name_and_path', + format: false + end end end - end - member do - get :status - post :cancel - post :retry - post :play - post :erase - get :trace, defaults: { format: 'json' } - get :raw - end + member do + get :status + post :cancel + post :retry + post :play + post :erase + get :trace, defaults: { format: 'json' } + get :raw + end - resource :artifacts, only: [] do - get :download - get :browse, path: 'browse(/*path)', format: false - get :file, path: 'file/*path', format: false - get :raw, path: 'raw/*path', format: false - post :keep + resource :artifacts, only: [] do + get :download + get :browse, path: 'browse(/*path)', format: false + get :file, path: 'file/*path', format: false + get :raw, path: 'raw/*path', format: false + post :keep + end end end + Gitlab::Routes::LegacyBuilds.new(self).draw + resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do member do get :test end + + resources :hook_logs, only: [:show] do + member do + get :retry + end + end end resources :container_registry, only: [:index, :destroy], @@ -234,7 +269,7 @@ constraints(ProjectUrlConstrainer.new) do get :referenced_merge_requests get :related_branches get :can_create_branch - get :rendered_title + get :realtime_changes post :create_merge_request end collection do @@ -305,7 +340,7 @@ constraints(ProjectUrlConstrainer.new) do resources :runner_projects, only: [:create, :destroy] resources :badges, only: [:index] do collection do - scope '*ref', constraints: { ref: Gitlab::Regex.git_reference_regex } do + scope '*ref', constraints: { ref: Gitlab::PathRegex.git_reference_regex } do constraints format: /svg/ do get :build get :coverage @@ -328,7 +363,7 @@ constraints(ProjectUrlConstrainer.new) do resources(:projects, path: '/', - constraints: { id: Gitlab::Regex.project_route_regex }, + constraints: { id: Gitlab::PathRegex.project_route_regex }, only: [:edit, :show, :update, :destroy]) do member do put :transfer |