Skip to content
Snippets Groups Projects
Commit ad640bc5 authored by Douwe Maan's avatar Douwe Maan
Browse files

Use Namespace#full_path instead of #path where appropriate

parent 509ff2ab
No related branches found
No related tags found
No related merge requests found
Showing
with 102 additions and 106 deletions
Loading
Loading
@@ -39,7 +39,7 @@
$value = $block.find('.value');
$loading = $block.find('.block-loading').fadeOut();
if (issueUpdateURL) {
milestoneLinkTemplate = _.template('<a href="/<%- namespace %>/<%- path %>/milestones/<%- iid %>" class="bold has-tooltip" data-container="body" title="<%- remaining %>"><%- title %></a>');
milestoneLinkTemplate = _.template('<a href="/<%- full_path %>/milestones/<%- iid %>" class="bold has-tooltip" data-container="body" title="<%- remaining %>"><%- title %></a>');
milestoneLinkNoneTemplate = '<span class="no-value">None</span>';
collapsedSidebarLabelTemplate = _.template('<span class="has-tooltip" data-container="body" title="<%- remaining %>" data-placement="left"> <%- title %> </span>');
}
Loading
Loading
@@ -181,8 +181,7 @@
$selectbox.hide();
$value.css('display', '');
if (data.milestone != null) {
data.milestone.namespace = _this.currentProject.namespace;
data.milestone.path = _this.currentProject.path;
data.milestone.full_path = _this.currentProject.full_path;
data.milestone.remaining = gl.utils.timeFor(data.milestone.due_date);
$value.html(milestoneLinkTemplate(data.milestone));
return $sidebarCollapsedValue.find('span').html(collapsedSidebarLabelTemplate(data.milestone));
Loading
Loading
Loading
Loading
@@ -52,7 +52,7 @@ module IssuablesHelper
field_name: 'issuable_template',
selected: selected_template(issuable),
project_path: ref_project.path,
namespace_path: ref_project.namespace.path
namespace_path: ref_project.namespace.full_path
}
}
 
Loading
Loading
Loading
Loading
@@ -360,7 +360,7 @@ class Project < ActiveRecord::Base
end
 
def reference_pattern
name_pattern = Gitlab::Regex::NAMESPACE_REGEX_STR
name_pattern = Gitlab::Regex::FULL_NAMESPACE_REGEX_STR
 
%r{
((?<namespace>#{name_pattern})\/)?
Loading
Loading
@@ -848,10 +848,6 @@ class Project < ActiveRecord::Base
gitlab_shell.url_to_repo(path_with_namespace)
end
 
def namespace_dir
namespace.try(:path) || ''
end
def repo_exists?
@repo_exists ||= repository.exists?
rescue
Loading
Loading
@@ -900,8 +896,8 @@ class Project < ActiveRecord::Base
 
def rename_repo
path_was = previous_changes['path'].first
old_path_with_namespace = File.join(namespace_dir, path_was)
new_path_with_namespace = File.join(namespace_dir, path)
old_path_with_namespace = File.join(namespace.full_path, path_was)
new_path_with_namespace = File.join(namespace.full_path, path)
 
Rails.logger.error "Attempting to rename #{old_path_with_namespace} -> #{new_path_with_namespace}"
 
Loading
Loading
Loading
Loading
@@ -334,7 +334,7 @@ class User < ActiveRecord::Base
def reference_pattern
%r{
#{Regexp.escape(reference_prefix)}
(?<user>#{Gitlab::Regex::NAMESPACE_REF_REGEX_STR})
(?<user>#{Gitlab::Regex::FULL_NAMESPACE_REGEX_STR})
}x
end
end
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@
= f.text_field :name, class: "form-control top", required: true, title: "This field is required."
.username.form-group
= f.label :username
= f.text_field :username, class: "form-control middle", pattern: Gitlab::Regex::NAMESPACE_REGEX_STR_SIMPLE, required: true, title: 'Please create a username with only alphanumeric characters.'
= f.text_field :username, class: "form-control middle", pattern: Gitlab::Regex::NAMESPACE_REGEX_STR_JS, required: true, title: 'Please create a username with only alphanumeric characters.'
%p.validation-error.hide Username is already taken.
%p.validation-success.hide Username is available.
%p.validation-pending.hide Checking username availability...
Loading
Loading
Loading
Loading
@@ -120,7 +120,7 @@
.form-group
- if @project.avatar?
.avatar-container.s160
= project_icon("#{@project.namespace.to_param}/#{@project.to_param}", alt: '', class: 'avatar project-avatar s160')
= project_icon(@project.full_path, alt: '', class: 'avatar project-avatar s160')
%p.light
- if @project.avatar_in_git
Project avatar in repository: #{ @project.avatar_in_git }
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@
%strong= parent.full_path + '/'
= f.text_field :path, placeholder: 'open-source', class: 'form-control',
autofocus: local_assigns[:autofocus] || false, required: true,
pattern: Gitlab::Regex::NAMESPACE_REGEX_STR_SIMPLE,
pattern: Gitlab::Regex::NAMESPACE_REGEX_STR_JS,
title: 'Please choose a group name with no special characters.'
- if parent
= f.hidden_field :parent_id, value: parent.id
Loading
Loading
Loading
Loading
@@ -173,7 +173,7 @@
:javascript
gl.IssuableResource = new gl.SubbableResource('#{issuable_json_path(issuable)}');
new gl.IssuableTimeTracking("#{escape_javascript(serialize_issuable(issuable))}");
new MilestoneSelect('{"namespace":"#{@project.namespace.path}","path":"#{@project.path}"}');
new MilestoneSelect('{"full_path":"#{@project.full_path}"}');
new LabelsSelect();
new IssuableContext('#{escape_javascript(current_user.to_json(only: [:username, :id, :name]))}');
gl.Subscription.bindAll('.subscription');
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ module Gitlab
end
 
def export_filename(project:)
basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{project.namespace.full_path}_#{project.path}"
basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{project.full_path.tr('/', '_')}"
 
"#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
end
Loading
Loading
Loading
Loading
@@ -5,17 +5,18 @@ module Gitlab
# The namespace regex is used in Javascript to validate usernames in the "Register" form. However, Javascript
# does not support the negative lookbehind assertion (?<!) that disallows usernames ending in `.git` and `.atom`.
# Since this is a non-trivial problem to solve in Javascript (heavily complicate the regex, modify view code to
# allow non-regex validatiions, etc), `NAMESPACE_REGEX_STR_SIMPLE` serves as a Javascript-compatible version of
# allow non-regex validatiions, etc), `NAMESPACE_REGEX_STR_JS` serves as a Javascript-compatible version of
# `NAMESPACE_REGEX_STR`, with the negative lookbehind assertion removed. This means that the client-side validation
# will pass for usernames ending in `.atom` and `.git`, but will be caught by the server-side validation.
PATH_REGEX_STR = '[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*'.freeze
NAMESPACE_REGEX_STR_SIMPLE = PATH_REGEX_STR + '[a-zA-Z0-9_\-]|[a-zA-Z0-9_]'.freeze
NAMESPACE_REGEX_STR = '(?:' + NAMESPACE_REGEX_STR_SIMPLE + ')(?<!\.git|\.atom)'.freeze
PROJECT_REGEX_STR = PATH_REGEX_STR + '(?<!\.git|\.atom)'.freeze
NAMESPACE_REGEX_STR_JS = PATH_REGEX_STR + '[a-zA-Z0-9_\-]|[a-zA-Z0-9_]'.freeze
NO_SUFFIX_REGEX_STR = '(?<!\.git|\.atom)'.freeze
NAMESPACE_REGEX_STR = "(?:#{NAMESPACE_REGEX_STR_JS})#{NO_SUFFIX_REGEX_STR}".freeze
PROJECT_REGEX_STR = "(?:#{PATH_REGEX_STR})#{NO_SUFFIX_REGEX_STR}".freeze
 
# Same as NAMESPACE_REGEX_STR but allows `/` in the path.
# So `group/subgroup` will match this regex but not NAMESPACE_REGEX_STR
NAMESPACE_REF_REGEX_STR = '(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.\/]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])(?<!\.git|\.atom)'.freeze
FULL_NAMESPACE_REGEX_STR = "(?:#{NAMESPACE_REGEX_STR}/)*#{NAMESPACE_REGEX_STR}".freeze
 
def namespace_regex
@namespace_regex ||= /\A#{NAMESPACE_REGEX_STR}\z/.freeze
Loading
Loading
Loading
Loading
@@ -19,8 +19,8 @@ describe Projects::BlobController do
 
before do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: id)
end
 
Loading
Loading
@@ -50,8 +50,8 @@ describe Projects::BlobController do
 
before do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: id)
controller.instance_variable_set(:@blob, nil)
end
Loading
Loading
Loading
Loading
@@ -16,8 +16,8 @@ describe Projects::BlameController do
 
before do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: id)
end
 
Loading
Loading
Loading
Loading
@@ -14,8 +14,8 @@ describe Projects::BlobController do
render_views
 
def do_get(opts = {})
params = { namespace_id: project.namespace.to_param,
project_id: project.to_param,
params = { namespace_id: project.namespace,
project_id: project,
id: 'master/CHANGELOG' }
get :diff, params.merge(opts)
end
Loading
Loading
@@ -40,8 +40,8 @@ describe Projects::BlobController do
describe 'PUT update' do
let(:default_params) do
{
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: 'master/CHANGELOG',
target_branch: 'master',
content: 'Added changes',
Loading
Loading
@@ -96,8 +96,8 @@ describe Projects::BlobController do
 
context 'when editing on the fork' do
before do
default_params[:namespace_id] = forked_project.namespace.to_param
default_params[:project_id] = forked_project.to_param
default_params[:namespace_id] = forked_project.namespace
default_params[:project_id] = forked_project
end
 
it 'redirects to blob' do
Loading
Loading
Loading
Loading
@@ -90,7 +90,7 @@ describe Projects::Boards::IssuesController do
 
params = {
namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
list_id: list.try(:to_param)
}
Loading
Loading
@@ -146,7 +146,7 @@ describe Projects::Boards::IssuesController do
sign_in(user)
 
post :create, namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
list_id: list.to_param,
issue: { title: title },
Loading
Loading
@@ -209,7 +209,7 @@ describe Projects::Boards::IssuesController do
sign_in(user)
 
patch :update, namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
id: issue.to_param,
from_list_id: from_list_id,
Loading
Loading
Loading
Loading
@@ -47,7 +47,7 @@ describe Projects::Boards::ListsController do
sign_in(user)
 
get :index, namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
format: :json
end
Loading
Loading
@@ -104,7 +104,7 @@ describe Projects::Boards::ListsController do
sign_in(user)
 
post :create, namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
list: { label_id: label_id },
format: :json
Loading
Loading
@@ -157,7 +157,7 @@ describe Projects::Boards::ListsController do
sign_in(user)
 
patch :update, namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
id: list.to_param,
list: { position: position },
Loading
Loading
@@ -200,7 +200,7 @@ describe Projects::Boards::ListsController do
sign_in(user)
 
delete :destroy, namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
id: list.to_param,
format: :json
Loading
Loading
@@ -244,7 +244,7 @@ describe Projects::Boards::ListsController do
sign_in(user)
 
post :generate, namespace_id: project.namespace.to_param,
project_id: project.to_param,
project_id: project,
board_id: board.to_param,
format: :json
end
Loading
Loading
Loading
Loading
@@ -50,8 +50,8 @@ describe Projects::BoardsController do
end
 
def list_boards(format: :html)
get :index, namespace_id: project.namespace.to_param,
project_id: project.to_param,
get :index, namespace_id: project.namespace,
project_id: project,
format: format
end
end
Loading
Loading
@@ -100,8 +100,8 @@ describe Projects::BoardsController do
end
 
def read_board(board:, format: :html)
get :show, namespace_id: project.namespace.to_param,
project_id: project.to_param,
get :show, namespace_id: project.namespace,
project_id: project,
id: board.to_param,
format: format
end
Loading
Loading
Loading
Loading
@@ -22,8 +22,8 @@ describe Projects::BranchesController do
sign_in(user)
 
post :create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
branch_name: branch,
ref: ref
end
Loading
Loading
@@ -76,8 +76,8 @@ describe Projects::BranchesController do
 
it 'redirects' do
post :create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
branch_name: branch,
issue_iid: issue.iid
 
Loading
Loading
@@ -89,8 +89,8 @@ describe Projects::BranchesController do
expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, "1-feature-branch")
 
post :create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
branch_name: branch,
issue_iid: issue.iid
end
Loading
Loading
@@ -106,8 +106,8 @@ describe Projects::BranchesController do
expect(SystemNoteService).not_to receive(:new_issue_branch)
 
post :create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
branch_name: branch,
issue_iid: issue.iid
end
Loading
Loading
@@ -126,8 +126,8 @@ describe Projects::BranchesController do
post :destroy,
format: :html,
id: 'foo/bar/baz',
namespace_id: project.namespace.to_param,
project_id: project.to_param
namespace_id: project.namespace,
project_id: project
 
expect(response).to have_http_status(303)
end
Loading
Loading
@@ -142,8 +142,8 @@ describe Projects::BranchesController do
post :destroy,
format: :js,
id: branch,
namespace_id: project.namespace.to_param,
project_id: project.to_param
namespace_id: project.namespace,
project_id: project
end
 
context "valid branch name, valid source" do
Loading
Loading
@@ -173,8 +173,8 @@ describe Projects::BranchesController do
describe "DELETE destroy_all_merged" do
def destroy_all_merged
delete :destroy_all_merged,
namespace_id: project.namespace.to_param,
project_id: project.to_param
namespace_id: project.namespace,
project_id: project
end
 
context 'when user is allowed to push' do
Loading
Loading
Loading
Loading
@@ -17,8 +17,8 @@ describe Projects::CommitController do
 
def go(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project.to_param
namespace_id: project.namespace,
project_id: project
}
 
get :show, params.merge(extra_params)
Loading
Loading
@@ -125,8 +125,8 @@ describe Projects::CommitController do
 
it 'renders it' do
get(:show,
namespace_id: fork_project.namespace.to_param,
project_id: fork_project.to_param,
namespace_id: fork_project.namespace,
project_id: fork_project,
id: commit.id)
 
expect(response).to be_success
Loading
Loading
@@ -139,8 +139,8 @@ describe Projects::CommitController do
commit = project.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
 
get(:branches,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: commit.id)
 
expect(assigns(:branches)).to include("master", "feature_conflict")
Loading
Loading
@@ -152,8 +152,8 @@ describe Projects::CommitController do
context 'when target branch is not provided' do
it 'renders the 404 page' do
post(:revert,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: commit.id)
 
expect(response).not_to be_success
Loading
Loading
@@ -164,8 +164,8 @@ describe Projects::CommitController do
context 'when the revert was successful' do
it 'redirects to the commits page' do
post(:revert,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
target_branch: 'master',
id: commit.id)
 
Loading
Loading
@@ -177,8 +177,8 @@ describe Projects::CommitController do
context 'when the revert failed' do
before do
post(:revert,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
target_branch: 'master',
id: commit.id)
end
Loading
Loading
@@ -186,8 +186,8 @@ describe Projects::CommitController do
it 'redirects to the commit page' do
# Reverting a commit that has been already reverted.
post(:revert,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
target_branch: 'master',
id: commit.id)
 
Loading
Loading
@@ -201,8 +201,8 @@ describe Projects::CommitController do
context 'when target branch is not provided' do
it 'renders the 404 page' do
post(:cherry_pick,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: master_pickable_commit.id)
 
expect(response).not_to be_success
Loading
Loading
@@ -213,8 +213,8 @@ describe Projects::CommitController do
context 'when the cherry-pick was successful' do
it 'redirects to the commits page' do
post(:cherry_pick,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
target_branch: 'master',
id: master_pickable_commit.id)
 
Loading
Loading
@@ -226,8 +226,8 @@ describe Projects::CommitController do
context 'when the cherry_pick failed' do
before do
post(:cherry_pick,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
target_branch: 'master',
id: master_pickable_commit.id)
end
Loading
Loading
@@ -235,8 +235,8 @@ describe Projects::CommitController do
it 'redirects to the commit page' do
# Cherry-picking a commit that has been already cherry-picked.
post(:cherry_pick,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
target_branch: 'master',
id: master_pickable_commit.id)
 
Loading
Loading
@@ -249,8 +249,8 @@ describe Projects::CommitController do
describe 'GET diff_for_path' do
def diff_for_path(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project.to_param
namespace_id: project.namespace,
project_id: project
}
 
get :diff_for_path, params.merge(extra_params)
Loading
Loading
@@ -313,8 +313,8 @@ describe Projects::CommitController do
describe 'GET pipelines' do
def get_pipelines(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project.to_param
namespace_id: project.namespace,
project_id: project
}
 
get :pipelines, params.merge(extra_params)
Loading
Loading
Loading
Loading
@@ -16,8 +16,8 @@ describe Projects::CommitsController do
context "when the ref does not exist with the suffix" do
it "renders as atom" do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: "master.atom")
 
expect(response).to be_success
Loading
Loading
@@ -33,8 +33,8 @@ describe Projects::CommitsController do
allow_any_instance_of(Repository).to receive(:commit).with('master.atom').and_return(commit)
 
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
id: "master.atom")
end
 
Loading
Loading
Loading
Loading
@@ -13,8 +13,8 @@ describe Projects::CompareController do
 
it 'compare shows some diffs' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
from: ref_from,
to: ref_to)
 
Loading
Loading
@@ -25,8 +25,8 @@ describe Projects::CompareController do
 
it 'compare shows some diffs with ignore whitespace change option' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
from: '08f22f25',
to: '66eceea0',
w: 1)
Loading
Loading
@@ -43,8 +43,8 @@ describe Projects::CompareController do
describe 'non-existent refs' do
it 'uses invalid source ref' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
from: 'non-existent',
to: ref_to)
 
Loading
Loading
@@ -55,8 +55,8 @@ describe Projects::CompareController do
 
it 'uses invalid target ref' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
from: ref_from,
to: 'non-existent')
 
Loading
Loading
@@ -67,8 +67,8 @@ describe Projects::CompareController do
 
it 'redirects back to index when params[:from] is empty and preserves params[:to]' do
post(:create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
from: '',
to: 'master')
 
Loading
Loading
@@ -77,8 +77,8 @@ describe Projects::CompareController do
 
it 'redirects back to index when params[:to] is empty and preserves params[:from]' do
post(:create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
from: 'master',
to: '')
 
Loading
Loading
@@ -87,8 +87,8 @@ describe Projects::CompareController do
 
it 'redirects back to index when params[:from] and params[:to] are empty' do
post(:create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_id: project.namespace,
project_id: project,
from: '',
to: '')
 
Loading
Loading
@@ -99,8 +99,8 @@ describe Projects::CompareController do
describe 'GET diff_for_path' do
def diff_for_path(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project.to_param
namespace_id: project.namespace,
project_id: project
}
 
get :diff_for_path, params.merge(extra_params)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment