...@@ -163,7 +163,7 @@ export const createCommitPayload = ({ ...@@ -163,7 +163,7 @@ export const createCommitPayload = ({
}); });
export const createNewMergeRequestUrl = (projectUrl, source, target) => export const createNewMergeRequestUrl = (projectUrl, source, target) =>
`${projectUrl}/-/merge_requests/new?merge_request[source_branch]=${source}&merge_request[target_branch]=${target}&nav_source=webide`; `${projectUrl}/merge_requests/new?merge_request[source_branch]=${source}&merge_request[target_branch]=${target}&nav_source=webide`;
const sortTreesByTypeAndName = (a, b) => { const sortTreesByTypeAndName = (a, b) => {
if (a.type === 'tree' && b.type === 'blob') { if (a.type === 'tree' && b.type === 'blob') {
... ...
......
...@@ -32,17 +32,17 @@ import { __ } from './locale'; ...@@ -32,17 +32,17 @@ import { __ } from './locale';
// //
// <ul class="nav-links merge-request-tabs"> // <ul class="nav-links merge-request-tabs">
// <li class="notes-tab active"> // <li class="notes-tab active">
// <a data-action="notes" data-target="#notes" data-toggle="tab" href="/foo/bar/-/merge_requests/1"> // <a data-action="notes" data-target="#notes" data-toggle="tab" href="/foo/bar/merge_requests/1">
// Discussion // Discussion
// </a> // </a>
// </li> // </li>
// <li class="commits-tab"> // <li class="commits-tab">
// <a data-action="commits" data-target="#commits" data-toggle="tab" href="/foo/bar/-/merge_requests/1/commits"> // <a data-action="commits" data-target="#commits" data-toggle="tab" href="/foo/bar/merge_requests/1/commits">
// Commits // Commits
// </a> // </a>
// </li> // </li>
// <li class="diffs-tab"> // <li class="diffs-tab">
// <a data-action="diffs" data-target="#diffs" data-toggle="tab" href="/foo/bar/-/merge_requests/1/diffs"> // <a data-action="diffs" data-target="#diffs" data-toggle="tab" href="/foo/bar/merge_requests/1/diffs">
// Diffs // Diffs
// </a> // </a>
// </li> // </li>
...@@ -260,17 +260,17 @@ export default class MergeRequestTabs { ...@@ -260,17 +260,17 @@ export default class MergeRequestTabs {
// //
// Examples: // Examples:
// //
// location.pathname # => "/namespace/project/-/merge_requests/1" // location.pathname # => "/namespace/project/merge_requests/1"
// setCurrentAction('diffs') // setCurrentAction('diffs')
// location.pathname # => "/namespace/project/-/merge_requests/1/diffs" // location.pathname # => "/namespace/project/merge_requests/1/diffs"
// //
// location.pathname # => "/namespace/project/-/merge_requests/1/diffs" // location.pathname # => "/namespace/project/merge_requests/1/diffs"
// setCurrentAction('show') // setCurrentAction('show')
// location.pathname # => "/namespace/project/-/merge_requests/1" // location.pathname # => "/namespace/project/merge_requests/1"
// //
// location.pathname # => "/namespace/project/-/merge_requests/1/diffs" // location.pathname # => "/namespace/project/merge_requests/1/diffs"
// setCurrentAction('commits') // setCurrentAction('commits')
// location.pathname # => "/namespace/project/-/merge_requests/1/commits" // location.pathname # => "/namespace/project/merge_requests/1/commits"
// //
// Returns the new URL String // Returns the new URL String
setCurrentAction(action) { setCurrentAction(action) {
... ...
......
...@@ -104,10 +104,10 @@ export default { ...@@ -104,10 +104,10 @@ export default {
return acc.concat({ return acc.concat({
name, name,
path, path,
to: `/-/tree/${this.ref}${path}`, to: `/tree/${this.ref}${path}`,
}); });
}, },
[{ name: this.projectShortPath, path: '/', to: `/-/tree/${this.ref}/` }], [{ name: this.projectShortPath, path: '/', to: `/tree/${this.ref}/` }],
); );
}, },
canCreateMrFromFork() { canCreateMrFromFork() {
... ...
......
...@@ -15,7 +15,7 @@ export default { ...@@ -15,7 +15,7 @@ export default {
const splitArray = this.path.split('/'); const splitArray = this.path.split('/');
splitArray.pop(); splitArray.pop();
return { path: `/-/tree/${this.commitRef}/${splitArray.join('/')}` }; return { path: `/tree/${this.commitRef}/${splitArray.join('/')}` };
}, },
}, },
methods: { methods: {
... ...
......
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
}, },
computed: { computed: {
routerLinkTo() { routerLinkTo() {
return this.isFolder ? { path: `/-/tree/${this.ref}/${this.path}` } : null; return this.isFolder ? { path: `/tree/${this.ref}/${this.path}` } : null;
}, },
iconName() { iconName() {
return `fa-${getIconName(this.type, this.path)}`; return `fa-${getIconName(this.type, this.path)}`;
... ...
......
...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) { ...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) {
base: joinPaths(gon.relative_url_root || '', base), base: joinPaths(gon.relative_url_root || '', base),
routes: [ routes: [
{ {
path: `/-/tree/${baseRef}(/.*)?`, path: `/tree/${baseRef}(/.*)?`,
name: 'treePath', name: 'treePath',
component: TreePage, component: TreePage,
props: route => ({ props: route => ({
... ...
......
...@@ -79,10 +79,10 @@ export default { ...@@ -79,10 +79,10 @@ export default {
return this.projectPath.indexOf('/') === 0 ? '' : `${gon.relative_url_root}/`; return this.projectPath.indexOf('/') === 0 ? '' : `${gon.relative_url_root}/`;
}, },
fullOldPath() { fullOldPath() {
return `${this.basePath}${this.projectPath}/-/raw/${this.oldSha}/${this.oldPath}`; return `${this.basePath}${this.projectPath}/raw/${this.oldSha}/${this.oldPath}`;
}, },
fullNewPath() { fullNewPath() {
return `${this.basePath}${this.projectPath}/-/raw/${this.newSha}/${this.newPath}`; return `${this.basePath}${this.projectPath}/raw/${this.newSha}/${this.newPath}`;
}, },
}, },
}; };
... ...
......
...@@ -43,8 +43,6 @@ module SubmoduleHelper ...@@ -43,8 +43,6 @@ module SubmoduleHelper
elsif github_dot_com_url?(url) elsif github_dot_com_url?(url)
standard_links('github.com', namespace, project, submodule_item_id) standard_links('github.com', namespace, project, submodule_item_id)
elsif gitlab_dot_com_url?(url) elsif gitlab_dot_com_url?(url)
# This need to be replaced with /-/tree routing once one is landed on
# GitLab.com. Issue https://gitlab.com/gitlab-org/gitlab/issues/42764
standard_links('gitlab.com', namespace, project, submodule_item_id) standard_links('gitlab.com', namespace, project, submodule_item_id)
else else
[sanitize_submodule_url(url), nil] [sanitize_submodule_url(url), nil]
... ...
......
...@@ -38,13 +38,13 @@ module TreeHelper ...@@ -38,13 +38,13 @@ module TreeHelper
# many paths, as with a repository tree that has thousands of items. # many paths, as with a repository tree that has thousands of items.
def fast_project_blob_path(project, blob_path) def fast_project_blob_path(project, blob_path)
ActionDispatch::Journey::Router::Utils.escape_path( ActionDispatch::Journey::Router::Utils.escape_path(
File.join(relative_url_root, project.path_with_namespace, '-', 'blob', blob_path) File.join(relative_url_root, project.path_with_namespace, 'blob', blob_path)
) )
end end
def fast_project_tree_path(project, tree_path) def fast_project_tree_path(project, tree_path)
ActionDispatch::Journey::Router::Utils.escape_path( ActionDispatch::Journey::Router::Utils.escape_path(
File.join(relative_url_root, project.path_with_namespace, '-', 'tree', tree_path) File.join(relative_url_root, project.path_with_namespace, 'tree', tree_path)
) )
end end
... ...
......
...@@ -62,7 +62,7 @@ module ChatMessage ...@@ -62,7 +62,7 @@ module ChatMessage
end end
def merge_request_url def merge_request_url
"#{project_url}/-/merge_requests/#{merge_request_iid}" "#{project_url}/merge_requests/#{merge_request_iid}"
end end
# overridden in EE # overridden in EE
... ...
......
...@@ -184,7 +184,7 @@ class HipchatService < Service ...@@ -184,7 +184,7 @@ class HipchatService < Service
description = obj_attr[:description] description = obj_attr[:description]
title = render_line(obj_attr[:title]) title = render_line(obj_attr[:title])
merge_request_url = "#{project_url}/-/merge_requests/#{merge_request_id}" merge_request_url = "#{project_url}/merge_requests/#{merge_request_id}"
merge_request_link = "<a href=\"#{merge_request_url}\">merge request !#{merge_request_id}</a>" merge_request_link = "<a href=\"#{merge_request_url}\">merge request !#{merge_request_id}</a>"
message = ["#{user_name} #{state} #{merge_request_link} in " \ message = ["#{user_name} #{state} #{merge_request_link} in " \
"#{project_link}: <b>#{title}</b>"] "#{project_link}: <b>#{title}</b>"]
... ...
......
---
title: Move merge request routes under /-/ scope
merge_request: 21126
author:
type: deprecated
---
title: Move repository routes under - scope
merge_request: 20455
author:
type: deprecated
...@@ -271,82 +271,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -271,82 +271,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do
member do
get :show # Insert this first to ensure redirections using merge_requests#show match this route
get :commit_change_content
post :merge
post :cancel_auto_merge
get :pipeline_status
get :ci_environments_status
post :toggle_subscription
post :remove_wip
post :assign_related_issues
get :discussions, format: :json
post :rebase
get :test_reports
get :exposed_artifacts
scope constraints: ->(req) { req.format == :json }, as: :json do
get :commits
get :pipelines
get :diffs, to: 'merge_requests/diffs#show'
get :diffs_batch, to: 'merge_requests/diffs#diffs_batch'
get :diffs_metadata, to: 'merge_requests/diffs#diffs_metadata'
get :widget, to: 'merge_requests/content#widget'
get :cached_widget, to: 'merge_requests/content#cached_widget'
end
scope action: :show do
get :commits, defaults: { tab: 'commits' }
get :pipelines, defaults: { tab: 'pipelines' }
get :diffs, defaults: { tab: 'diffs' }
end
get :diff_for_path, controller: 'merge_requests/diffs'
scope controller: 'merge_requests/conflicts' do
get :conflicts, action: :show
get :conflict_for_path
post :resolve_conflicts
end
end
collection do
get :diff_for_path
post :bulk_update
end
resources :discussions, only: [:show], constraints: { id: /\h{40}/ } do
member do
post :resolve
delete :resolve, action: :unresolve
end
end
end
scope path: 'merge_requests', controller: 'merge_requests/creations' do
post '', action: :create, as: nil
scope path: 'new', as: :new_merge_request do
get '', action: :new
scope constraints: ->(req) { req.format == :json }, as: :json do
get :diffs
get :pipelines
end
scope action: :new do
get :diffs, defaults: { tab: 'diffs' }
get :pipelines, defaults: { tab: 'pipelines' }
end
get :diff_for_path
get :branch_from
get :branch_to
end
end
# The wiki routing contains wildcard characters so # The wiki routing contains wildcard characters so
# its preferable to keep it below all other project routes # its preferable to keep it below all other project routes
draw :wiki draw :wiki
...@@ -404,6 +328,82 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -404,6 +328,82 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do
member do
get :show # Insert this first to ensure redirections using merge_requests#show match this route
get :commit_change_content
post :merge
post :cancel_auto_merge
get :pipeline_status
get :ci_environments_status
post :toggle_subscription
post :remove_wip
post :assign_related_issues
get :discussions, format: :json
post :rebase
get :test_reports
get :exposed_artifacts
scope constraints: ->(req) { req.format == :json }, as: :json do
get :commits
get :pipelines
get :diffs, to: 'merge_requests/diffs#show'
get :diffs_batch, to: 'merge_requests/diffs#diffs_batch'
get :diffs_metadata, to: 'merge_requests/diffs#diffs_metadata'
get :widget, to: 'merge_requests/content#widget'
get :cached_widget, to: 'merge_requests/content#cached_widget'
end
scope action: :show do
get :commits, defaults: { tab: 'commits' }
get :pipelines, defaults: { tab: 'pipelines' }
get :diffs, defaults: { tab: 'diffs' }
end
get :diff_for_path, controller: 'merge_requests/diffs'
scope controller: 'merge_requests/conflicts' do
get :conflicts, action: :show
get :conflict_for_path
post :resolve_conflicts
end
end
collection do
get :diff_for_path
post :bulk_update
end
resources :discussions, only: [:show], constraints: { id: /\h{40}/ } do
member do
post :resolve
delete :resolve, action: :unresolve
end
end
end
scope path: 'merge_requests', controller: 'merge_requests/creations' do
post '', action: :create, as: nil
scope path: 'new', as: :new_merge_request do
get '', action: :new
scope constraints: ->(req) { req.format == :json }, as: :json do
get :diffs
get :pipelines
end
scope action: :new do
get :diffs, defaults: { tab: 'diffs' }
get :pipelines, defaults: { tab: 'pipelines' }
end
get :diff_for_path
get :branch_from
get :branch_to
end
end
resources :pipelines, only: [:index, :new, :create, :show] do resources :pipelines, only: [:index, :new, :create, :show] do
collection do collection do
resource :pipelines_settings, path: 'settings', only: [:show, :update] resource :pipelines_settings, path: 'settings', only: [:show, :update]
...@@ -557,8 +557,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -557,8 +557,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
:forks, :group_links, :import, :avatar, :mirror, :forks, :group_links, :import, :avatar, :mirror,
:cycle_analytics, :mattermost, :variables, :triggers, :cycle_analytics, :mattermost, :variables, :triggers,
:environments, :protected_environments, :error_tracking, :environments, :protected_environments, :error_tracking,
:serverless, :clusters, :audit_events, :wikis, :merge_requests, :serverless, :clusters, :audit_events, :wikis)
:blob, :tree, :raw, :blame, :commits, :create_dir, :find_file, :files)
end end
# rubocop: disable Cop/PutProjectRoutesUnderScope # rubocop: disable Cop/PutProjectRoutesUnderScope
... ...
......
...@@ -65,7 +65,7 @@ scope format: false do ...@@ -65,7 +65,7 @@ scope format: false do
resources :protected_tags, only: [:index, :show, :create, :update, :destroy] resources :protected_tags, only: [:index, :show, :create, :update, :destroy]
end end
scope path: '-', constraints: { id: /[^\0]+/ } do scope constraints: { id: /[^\0]+/ } do
scope controller: :blob do scope controller: :blob do
get '/new/*id', action: :new, as: :new_blob get '/new/*id', action: :new, as: :new_blob
post '/create/*id', action: :create, as: :create_blob post '/create/*id', action: :create, as: :create_blob
... ...
......
...@@ -152,18 +152,11 @@ module Banzai ...@@ -152,18 +152,11 @@ module Banzai
def rebuild_relative_uri(uri) def rebuild_relative_uri(uri)
file_path = nested_file_path_if_exists(uri) file_path = nested_file_path_if_exists(uri)
resource_type = uri_type(file_path)
# Repository routes are under /-/ scope now.
# Since we craft a path without using route helpers we must
# ensure - is added here.
prefix = '-' if %w(tree blob raw commits).include?(resource_type.to_s)
uri.path = [ uri.path = [
relative_url_root, relative_url_root,
project.full_path, project.full_path,
prefix, uri_type(file_path),
resource_type,
Addressable::URI.escape(ref).gsub('#', '%23'), Addressable::URI.escape(ref).gsub('#', '%23'),
Addressable::URI.escape(file_path) Addressable::URI.escape(file_path)
].compact.join('/').squeeze('/').chomp('/') ].compact.join('/').squeeze('/').chomp('/')
... ...
......
...@@ -12,12 +12,10 @@ module Gitlab ...@@ -12,12 +12,10 @@ module Gitlab
def link_dependencies def link_dependencies
link_json('ImportPath') do |path| link_json('ImportPath') do |path|
case path case path
when %r{\A(?<repo>github\.com/#{REPO_REGEX})/(?<path>.+)\z}
"https://#{$~[:repo]}/tree/master/#{$~[:path]}"
when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z}, when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z},
%r{\A(?<repo>gitlab\.com/#{REPO_REGEX})/(?<path>.+)\z} %r{\A(?<repo>git(lab|hub)\.com/#{REPO_REGEX})/(?<path>.+)\z}
"https://#{$~[:repo]}/-/tree/master/#{$~[:path]}" "https://#{$~[:repo]}/tree/master/#{$~[:path]}"
when /\Agolang\.org/ when /\Agolang\.org/
"https://godoc.org/#{path}" "https://godoc.org/#{path}"
else else
... ...
......
...@@ -60,7 +60,7 @@ module Gitlab ...@@ -60,7 +60,7 @@ module Gitlab
end end
meta_import_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}" meta_import_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}"
meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}" meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/tree/#{branch}{/dir} #{project_url}/blob/#{branch}{/dir}/{file}#L{line}"
head_tag = content_tag :head, meta_import_tag + meta_source_tag head_tag = content_tag :head, meta_import_tag + meta_source_tag
html_tag = content_tag :html, head_tag + body_tag html_tag = content_tag :html, head_tag + body_tag
[html_tag, 200] [html_tag, 200]
... ...
......
...@@ -13328,6 +13328,9 @@ msgstr "" ...@@ -13328,6 +13328,9 @@ msgstr ""
msgid "ProductivityAanalytics|Merge requests" msgid "ProductivityAanalytics|Merge requests"
msgstr "" msgstr ""
msgid "ProductivityAanalytics|is earlier than the allowed minimum date"
msgstr ""
msgid "ProductivityAnalytics|Ascending" msgid "ProductivityAnalytics|Ascending"
msgstr "" msgstr ""
...@@ -13361,6 +13364,9 @@ msgstr "" ...@@ -13361,6 +13364,9 @@ msgstr ""
msgid "ProductivityAnalytics|Trendline" msgid "ProductivityAnalytics|Trendline"
msgstr "" msgstr ""
msgid "ProductivityAnalytics|is earlier than the given merged at after date"
msgstr ""
msgid "Profile" msgid "Profile"
msgstr "" msgstr ""
... ...
......
...@@ -72,7 +72,7 @@ describe MetricsDashboard do ...@@ -72,7 +72,7 @@ describe MetricsDashboard do
it 'includes project_blob_path only for project dashboards' do it 'includes project_blob_path only for project dashboards' do
expect(system_dashboard['project_blob_path']).to be_nil expect(system_dashboard['project_blob_path']).to be_nil
expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/-/blob/master/.gitlab/dashboards/test.yml") expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/blob/master/.gitlab/dashboards/test.yml")
end end
describe 'project permissions' do describe 'project permissions' do
... ...
......