Commit 90cb2aab authored by Sean McGivern's avatar Sean McGivern

Merge branch '28283-legacy-storage-format' into 'master'

[CE] Added Legacy Storage format

See merge request !13149
parents fb1baaa7 2c260962
...@@ -40,7 +40,7 @@ module MergeRequestsHelper ...@@ -40,7 +40,7 @@ module MergeRequestsHelper
def merge_path_description(merge_request, separator) def merge_path_description(merge_request, separator)
if merge_request.for_fork? if merge_request.for_fork?
"Project:Branches: #{@merge_request.source_project_path}:#{@merge_request.source_branch} #{separator} #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch}" "Project:Branches: #{@merge_request.source_project_path}:#{@merge_request.source_branch} #{separator} #{@merge_request.target_project.full_path}:#{@merge_request.target_branch}"
else else
"Branches: #{@merge_request.source_branch} #{separator} #{@merge_request.target_branch}" "Branches: #{@merge_request.source_branch} #{separator} #{@merge_request.target_branch}"
end end
......
...@@ -398,7 +398,7 @@ module ProjectsHelper ...@@ -398,7 +398,7 @@ module ProjectsHelper
if project if project
import_path = "/Home/Stacks/import" import_path = "/Home/Stacks/import"
repo = project.path_with_namespace repo = project.full_path
branch ||= project.default_branch branch ||= project.default_branch
sha ||= project.commit.short_id sha ||= project.commit.short_id
...@@ -458,7 +458,7 @@ module ProjectsHelper ...@@ -458,7 +458,7 @@ module ProjectsHelper
def readme_cache_key def readme_cache_key
sha = @project.commit.try(:sha) || 'nil' sha = @project.commit.try(:sha) || 'nil'
[@project.path_with_namespace, sha, "readme"].join('-') [@project.full_path, sha, "readme"].join('-')
end end
def current_ref def current_ref
......
...@@ -165,7 +165,7 @@ class Notify < BaseMailer ...@@ -165,7 +165,7 @@ class Notify < BaseMailer
headers['X-GitLab-Project'] = @project.name headers['X-GitLab-Project'] = @project.name
headers['X-GitLab-Project-Id'] = @project.id headers['X-GitLab-Project-Id'] = @project.id
headers['X-GitLab-Project-Path'] = @project.path_with_namespace headers['X-GitLab-Project-Path'] = @project.full_path
end end
def add_unsubscription_headers_and_links def add_unsubscription_headers_and_links
......
...@@ -317,7 +317,7 @@ module Ci ...@@ -317,7 +317,7 @@ module Ci
return @config_processor if defined?(@config_processor) return @config_processor if defined?(@config_processor)
@config_processor ||= begin @config_processor ||= begin
Ci::GitlabCiYamlProcessor.new(ci_yaml_file, project.path_with_namespace) Ci::GitlabCiYamlProcessor.new(ci_yaml_file, project.full_path)
rescue Ci::GitlabCiYamlProcessor::ValidationError, Psych::SyntaxError => e rescue Ci::GitlabCiYamlProcessor::ValidationError, Psych::SyntaxError => e
self.yaml_errors = e.message self.yaml_errors = e.message
nil nil
......
module Storage
module LegacyNamespace
extend ActiveSupport::Concern
def move_dir
if any_project_has_container_registry_tags?
raise Gitlab::UpdatePathError.new('Namespace cannot be moved, because at least one project has tags in container registry')
end
# Move the namespace directory in all storage paths used by member projects
repository_storage_paths.each do |repository_storage_path|
# Ensure old directory exists before moving it
gitlab_shell.add_namespace(repository_storage_path, full_path_was)
unless gitlab_shell.mv_namespace(repository_storage_path, full_path_was, full_path)
Rails.logger.error "Exception moving path #{repository_storage_path} from #{full_path_was} to #{full_path}"
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise Gitlab::UpdatePathError.new('namespace directory cannot be moved')
end
end
Gitlab::UploadsTransfer.new.rename_namespace(full_path_was, full_path)
Gitlab::PagesTransfer.new.rename_namespace(full_path_was, full_path)
remove_exports!
# If repositories moved successfully we need to
# send update instructions to users.
# However we cannot allow rollback since we moved namespace dir
# So we basically we mute exceptions in next actions
begin
send_update_instructions
true
rescue
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
false
end
end
# Hooks
# Save the storage paths before the projects are destroyed to use them on after destroy
def prepare_for_destroy
old_repository_storage_paths
end
private
def old_repository_storage_paths
@old_repository_storage_paths ||= repository_storage_paths
end
def repository_storage_paths
# We need to get the storage paths for all the projects, even the ones that are
# pending delete. Unscoping also get rids of the default order, which causes
# problems with SELECT DISTINCT.
Project.unscoped do
all_projects.select('distinct(repository_storage)').to_a.map(&:repository_storage_path)
end
end
def rm_dir
# Remove the namespace directory in all storages paths used by member projects
old_repository_storage_paths.each do |repository_storage_path|
# Move namespace directory into trash.
# We will remove it later async
new_path = "#{full_path}+#{id}+deleted"
if gitlab_shell.mv_namespace(repository_storage_path, full_path, new_path)
Gitlab::AppLogger.info %Q(Namespace directory "#{full_path}" moved to "#{new_path}")
# Remove namespace directroy async with delay so
# GitLab has time to remove all projects first
run_after_commit do
GitlabShellWorker.perform_in(5.minutes, :rm_namespace, repository_storage_path, new_path)
end
end
end
remove_exports!
end
def remove_exports!
Gitlab::Popen.popen(%W(find #{export_path} -not -path #{export_path} -delete))
end
def export_path
File.join(Gitlab::ImportExport.storage_path, full_path_was)
end
def full_path_was
if parent
parent.full_path + '/' + path_was
else
path_was
end
end
end
end
module Storage
module LegacyProject
extend ActiveSupport::Concern
def disk_path
full_path
end
def ensure_storage_path_exist
gitlab_shell.add_namespace(repository_storage_path, namespace.full_path)
end
def rename_repo
path_was = previous_changes['path'].first
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}"
if has_container_registry_tags?
Rails.logger.error "Project #{old_path_with_namespace} cannot be renamed because container registry tags are present!"
# we currently doesn't support renaming repository if it contains images in container registry
raise StandardError.new('Project cannot be renamed, because images are present in its container registry')
end
expire_caches_before_rename(old_path_with_namespace)
if gitlab_shell.mv_repository(repository_storage_path, old_path_with_namespace, new_path_with_namespace)
# If repository moved successfully we need to send update instructions to users.
# However we cannot allow rollback since we moved repository
# So we basically we mute exceptions in next actions
begin
gitlab_shell.mv_repository(repository_storage_path, "#{old_path_with_namespace}.wiki", "#{new_path_with_namespace}.wiki")
send_move_instructions(old_path_with_namespace)
expires_full_path_cache
@old_path_with_namespace = old_path_with_namespace
SystemHooksService.new.execute_hooks_for(self, :rename)
@repository = nil
rescue => e
Rails.logger.error "Exception renaming #{old_path_with_namespace} -> #{new_path_with_namespace}: #{e}"
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
false
end
else
Rails.logger.error "Repository could not be renamed: #{old_path_with_namespace} -> #{new_path_with_namespace}"
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise StandardError.new('repository cannot be renamed')
end
Gitlab::AppLogger.info "Project was renamed: #{old_path_with_namespace} -> #{new_path_with_namespace}"
Gitlab::UploadsTransfer.new.rename_project(path_was, path, namespace.full_path)
Gitlab::PagesTransfer.new.rename_project(path_was, path, namespace.full_path)
end
def create_repository(force: false)
# Forked import is handled asynchronously
return if forked? && !force
if gitlab_shell.add_repository(repository_storage_path, path_with_namespace)
repository.after_create
true
else
errors.add(:base, 'Failed to create repository via gitlab-shell')
false
end
end
end
end
module Storage
module LegacyProjectWiki
extend ActiveSupport::Concern
def disk_path
project.disk_path + '.wiki'
end
end
end
module Storage
module LegacyRepository
extend ActiveSupport::Concern
delegate :disk_path, to: :project
end
end
...@@ -630,7 +630,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -630,7 +630,7 @@ class MergeRequest < ActiveRecord::Base
def target_project_path def target_project_path
if target_project if target_project
target_project.path_with_namespace target_project.full_path
else else
"(removed)" "(removed)"
end end
...@@ -638,7 +638,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -638,7 +638,7 @@ class MergeRequest < ActiveRecord::Base
def source_project_path def source_project_path
if source_project if source_project
source_project.path_with_namespace source_project.full_path
else else
"(removed)" "(removed)"
end end
......
...@@ -8,6 +8,7 @@ class Namespace < ActiveRecord::Base ...@@ -8,6 +8,7 @@ class Namespace < ActiveRecord::Base
include Gitlab::VisibilityLevel include Gitlab::VisibilityLevel
include Routable include Routable
include AfterCommitQueue include AfterCommitQueue
include Storage::LegacyNamespace
# Prevent users from creating unreasonably deep level of nesting. # Prevent users from creating unreasonably deep level of nesting.
# The number 20 was taken based on maximum nesting level of # The number 20 was taken based on maximum nesting level of
...@@ -41,10 +42,11 @@ class Namespace < ActiveRecord::Base ...@@ -41,10 +42,11 @@ class Namespace < ActiveRecord::Base
delegate :name, to: :owner, allow_nil: true, prefix: true delegate :name, to: :owner, allow_nil: true, prefix: true
after_update :move_dir, if: :path_changed?
after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') } after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') }
# Save the storage paths before the projects are destroyed to use them on after destroy # Legacy Storage specific hooks
after_update :move_dir, if: :path_changed?
before_destroy(prepend: true) { prepare_for_destroy } before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir after_destroy :rm_dir
...@@ -118,43 +120,6 @@ class Namespace < ActiveRecord::Base ...@@ -118,43 +120,6 @@ class Namespace < ActiveRecord::Base
owner_name owner_name
end end
def move_dir
if any_project_has_container_registry_tags?
raise Gitlab::UpdatePathError.new('Namespace cannot be moved, because at least one project has tags in container registry')
end
# Move the namespace directory in all storages paths used by member projects
repository_storage_paths.each do |repository_storage_path|
# Ensure old directory exists before moving it
gitlab_shell.add_namespace(repository_storage_path, full_path_was)
unless gitlab_shell.mv_namespace(repository_storage_path, full_path_was, full_path)
Rails.logger.error "Exception moving path #{repository_storage_path} from #{full_path_was} to #{full_path}"
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise Gitlab::UpdatePathError.new('namespace directory cannot be moved')
end
end
Gitlab::UploadsTransfer.new.rename_namespace(full_path_was, full_path)
Gitlab::PagesTransfer.new.rename_namespace(full_path_was, full_path)
remove_exports!
# If repositories moved successfully we need to
# send update instructions to users.
# However we cannot allow rollback since we moved namespace dir
# So we basically we mute exceptions in next actions
begin
send_update_instructions
rescue
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
false
end
end
def any_project_has_container_registry_tags? def any_project_has_container_registry_tags?
all_projects.any?(&:has_container_registry_tags?) all_projects.any?(&:has_container_registry_tags?)
end end
...@@ -206,14 +171,6 @@ class Namespace < ActiveRecord::Base ...@@ -206,14 +171,6 @@ class Namespace < ActiveRecord::Base
parent_id_changed? parent_id_changed?
end end
def prepare_for_destroy
old_repository_storage_paths
end
def old_repository_storage_paths
@old_repository_storage_paths ||= repository_storage_paths
end
# Includes projects from this namespace and projects from all subgroups # Includes projects from this namespace and projects from all subgroups
# that belongs to this namespace # that belongs to this namespace
def all_projects def all_projects
...@@ -232,37 +189,6 @@ class Namespace < ActiveRecord::Base ...@@ -232,37 +189,6 @@ class Namespace < ActiveRecord::Base
private private
def repository_storage_paths
# We need to get the storage paths for all the projects, even the ones that are
# pending delete. Unscoping also get rids of the default order, which causes
# problems with SELECT DISTINCT.
Project.unscoped do
all_projects.select('distinct(repository_storage)').to_a.map(&:repository_storage_path)
end
end
def rm_dir
# Remove the namespace directory in all storages paths used by member projects
old_repository_storage_paths.each do |repository_storage_path|
# Move namespace directory into trash.
# We will remove it later async
new_path = "#{full_path}+#{id}+deleted"
if gitlab_shell.mv_namespace(repository_storage_path, full_path, new_path)
message = "Namespace directory \"#{full_path}\" moved to \"#{new_path}\""
Gitlab::AppLogger.info message
# Remove namespace directroy async with delay so
# GitLab has time to remove all projects first
run_after_commit do
GitlabShellWorker.perform_in(5.minutes, :rm_namespace, repository_storage_path, new_path)
end
end
end
remove_exports!
end
def refresh_access_of_projects_invited_groups def refresh_access_of_projects_invited_groups
Group Group
.joins(project_group_links: :project) .joins(project_group_links: :project)
...@@ -270,22 +196,6 @@ class Namespace < ActiveRecord::Base ...@@ -270,22 +196,6 @@ class Namespace < ActiveRecord::Base
.find_each(&:refresh_members_authorized_projects) .find_each(&:refresh_members_authorized_projects)
end end
def remove_exports!
Gitlab::Popen.popen(%W(find #{export_path} -not -path #{export_path} -delete))
end
def export_path
File.join(Gitlab::ImportExport.storage_path, full_path_was)
end
def full_path_was
if parent
parent.full_path + '/' + path_was
else
path_was
end
end
def nesting_level_allowed def nesting_level_allowed
if ancestors.count > Group::NUMBER_OF_ANCESTORS_ALLOWED if ancestors.count > Group::NUMBER_OF_ANCESTORS_ALLOWED
errors.add(:parent_id, "has too deep level of nesting") errors.add(:parent_id, "has too deep level of nesting")
......
...@@ -17,6 +17,7 @@ class Project < ActiveRecord::Base ...@@ -17,6 +17,7 @@ class Project < ActiveRecord::Base
include ProjectFeaturesCompatibility include ProjectFeaturesCompatibility
include SelectForProjectAuthorization include SelectForProjectAuthorization
include Routable include Routable
include Storage::LegacyProject
extend Gitlab::ConfigHelper extend Gitlab::ConfigHelper
...@@ -43,9 +44,8 @@ class Project < ActiveRecord::Base ...@@ -43,9 +44,8 @@ class Project < ActiveRecord::Base
default_value_for :snippets_enabled, gitlab_config_features.snippets default_value_for :snippets_enabled, gitlab_config_features.snippets
default_value_for :only_allow_merge_if_all_discussions_are_resolved, false default_value_for :only_allow_merge_if_all_discussions_are_resolved, false
after_create :ensure_dir_exist after_create :ensure_storage_path_exist
after_create :create_project_feature, unless: :project_feature after_create :create_project_feature, unless: :project_feature
after_save :ensure_dir_exist, if: :namespace_id_changed?
after_save :update_project_statistics, if: :namespace_id_changed? after_save :update_project_statistics, if: :namespace_id_changed?
# set last_activity_at to the same as created_at # set last_activity_at to the same as created_at
...@@ -67,6 +67,10 @@ class Project < ActiveRecord::Base ...@@ -67,6 +67,10 @@ class Project < ActiveRecord::Base
after_validation :check_pending_delete after_validation :check_pending_delete
# Legacy Storage specific hooks
after_save :ensure_storage_path_exist, if: :namespace_id_changed?
acts_as_taggable acts_as_taggable
attr_accessor :new_default_branch attr_accessor :new_default_branch
...@@ -375,7 +379,7 @@ class Project < ActiveRecord::Base ...@@ -375,7 +379,7 @@ class Project < ActiveRecord::Base
begin begin
Projects::HousekeepingService.new(project).execute Projects::HousekeepingService.new(project).execute
rescue Projects::HousekeepingService::LeaseTaken => e rescue Projects::HousekeepingService::LeaseTaken => e
Rails.logger.info("Could not perform housekeeping for project #{project.path_with_namespace} (#{project.id}): #{e}") Rails.logger.info("Could not perform housekeeping for project #{project.full_path} (#{project.id}): #{e}")
end end
end end
end end
...@@ -476,12 +480,12 @@ class Project < ActiveRecord::Base ...@@ -476,12 +480,12 @@ class Project < ActiveRecord::Base
end end
def repository def repository
@repository ||= Repository.new(path_with_namespace, self) @repository ||= Repository.new(full_path, self, disk_path: disk_path)
end end
def container_registry_url def container_registry_url
if Gitlab.config.registry.enabled if Gitlab.config.registry.enabled
"#{Gitlab.config.registry.host_port}/#{path_with_namespace.downcase}" "#{Gitlab.config.registry.host_port}/#{full_path.downcase}"
end end
end end
...@@ -520,16 +524,16 @@ class Project < ActiveRecord::Base ...@@ -520,16 +524,16 @@ class Project < ActiveRecord::Base
job_id = job_id =
if forked? if forked?
RepositoryForkWorker.perform_async(id, forked_from_project.repository_storage_path, RepositoryForkWorker.perform_async(id, forked_from_project.repository_storage_path,
forked_from_project.path_with_namespace, forked_from_project.full_path,
self.namespace.full_path) self.namespace.full_path)
else else
RepositoryImportWorker.perform_async(self.id) RepositoryImportWorker.perform_async(self.id)
end end
if job_id if job_id
Rails.logger.info "Import job started for #{path_with_namespace} with job ID #{job_id}" Rails.logger.info "Import job started for #{full_path} with job ID #{job_id}"
else else
Rails.logger.error "Import job failed to start for #{path_with_namespace}" Rails.logger.error "Import job failed to start for #{full_path}"
end end
end end
...@@ -690,7 +694,7 @@ class Project < ActiveRecord::Base ...@@ -690,7 +694,7 @@ class Project < ActiveRecord::Base
# `from` argument can be a Namespace or Project. # `from` argument can be a Namespace or Project.
def to_reference(from = nil, full: false) def to_reference(from = nil, full: false)
if full || cross_namespace_reference?(from) if full || cross_namespace_reference?(from)
path_with_namespace full_path
elsif cross_project_reference?(from) elsif cross_project_reference?(from)
path path
end end
...@@ -714,7 +718,7 @@ class Project < ActiveRecord::Base ...@@ -714,7 +718,7 @@ class Project < ActiveRecord::Base
author.ensure_incoming_email_token! author.ensure_incoming_email_token!
Gitlab::IncomingEmail.reply_address( Gitlab::IncomingEmail.reply_address(
"#{path_with_namespace}+#{author.incoming_email_token}") "#{full_path}+#{author.incoming_email_token}")
end end
def build_commit_note(commit) def build_commit_note(commit)
...@@ -941,7 +945,7 @@ class Project < ActiveRecord::Base ...@@ -941,7 +945,7 @@ class Project < ActiveRecord::Base
end end
def url_to_repo def url_to_repo
gitlab_shell.url_to_repo(path_with_namespace) gitlab_shell.url_to_repo(full_path)
end end
def repo_exists? def repo_exists?
...@@ -974,56 +978,6 @@ class Project < ActiveRecord::Base ...@@ -974,56 +978,6 @@ class Project < ActiveRecord::Base
!group !group
end end
def rename_repo
path_was = previous_changes['path'].first
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}"
if has_container_registry_tags?
Rails.logger.error "Project #{old_path_with_namespace} cannot be renamed because container registry tags are present!"
# we currently doesn't support renaming repository if it contains images in container registry
raise StandardError.new('Project cannot be renamed, because images are present in its container registry')
end
expire_caches_before_rename(old_path_with_namespace)
if gitlab_shell.mv_repository(repository_storage_path, old_path_with_namespace, new_path_with_namespace)
# If repository moved successfully we need to send update instructions to users.
# However we cannot allow rollback since we moved repository
# So we basically we mute exceptions in next actions
begin
gitlab_shell.mv_repository(repository_storage_path, "#{old_path_with_namespace}.wiki", "#{new_path_with_namespace}.wiki")
send_move_instructions(old_path_with_namespace)
expires_full_path_cache
@old_path_with_namespace = old_path_with_namespace
SystemHooksService.new.execute_hooks_for(self, :rename)
@repository = nil
rescue => e
Rails.logger.error "Exception renaming #{old_path_with_namespace} -> #{new_path_with_namespace}: #{e}"
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
false
end
else
Rails.logger.error "Repository could not be renamed: #{old_path_with_namespace} -> #{new_path_with_namespace}"
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise StandardError.new('repository cannot be renamed')
end
Gitlab::AppLogger.info "Project was renamed: #{old_path_with_namespace} -> #{new_path_with_namespace}"
Gitlab::UploadsTransfer.new.rename_project(path_was, path, namespace.full_path)
Gitlab::PagesTransfer.new.rename_project(path_was, path, namespace.full_path)
end
# Expires various caches before a project is renamed. # Expires various caches before a project is renamed.
def expire_caches_before_rename(old_path) def expire_caches_before_rename(old_path)
repo = Repository.new(old_path, self) repo = Repository.new(old_path, self)
...@@ -1048,7 +1002,7 @@ class Project < ActiveRecord::Base ...@@ -1048,7 +1002,7 @@ class Project < ActiveRecord::Base
git_http_url: http_url_to_repo, git_http_url: http_url_to_repo,
namespace: namespace.name, namespace: namespace.name,
visibility_level: visibility_level, visibility_level: visibility_level,
path_with_namespace: path_with_namespace, path_with_namespace: full_path,
default_branch: default_branch, default_branch: default_branch,
ci_config_path: ci_config_path ci_config_path: ci_config_path
} }
...@@ -1109,19 +1063,6 @@ class Project < ActiveRecord::Base ...@@ -1109,19 +1063,6 @@ class Project < ActiveRecord::Base
merge_requests.where(source_project_id: self.id) merge_requests.where(source_project_id: self.id)
end end
def create_repository(force: false)
# Forked import is handled asynchronously
return if forked? && !force
if gitlab_shell.add_repository(repository_storage_path, path_with_namespace)
repository.after_create
true
else
errors.add(:base, 'Failed to create repository via gitlab-shell')
false
end
end
def ensure_repository def ensure_repository
create_repository(force: true) unless repository_exists? create_repository(force: true) unless repository_exists?
end end
...@@ -1257,7 +1198,7 @@ class Project < ActiveRecord::Base ...@@ -1257,7 +1198,7 @@ class Project < ActiveRecord::Base
end end
def pages_path def pages_path
File.join(Settings.pages.path, path_with_namespace) File.join(Settings.pages.path, disk_path)
end end
def public_pages_path def public_pages_path
...@@ -1279,6 +1220,7 @@ class Project < ActiveRecord::Base ...@@ -1279,6 +1220,7 @@ class Project < ActiveRecord::Base
.delete_all .delete_all
end end
# TODO: what to do here when not using Legacy Storage? Do we still need to rename and delay removal?
def remove_pages def remove_pages
::Projects::UpdatePagesConfigurationService.new(self).execute ::Projects::UpdatePagesConfigurationService.new(self).execute
...@@ -1326,7 +1268,7 @@ class Project < ActiveRecord::Base ...@@ -1326,7 +1268,7 @@ class Project < ActiveRecord::Base
end end
def export_path def export_path
File.join(Gitlab::ImportExport.storage_path, path_with_namespace) File.join(Gitlab::ImportExport.storage_path, disk_path)
end end
def export_project_path def export_project_path
...@@ -1338,16 +1280,12 @@ class Project < ActiveRecord::Base ...@@ -1338,16 +1280,12 @@ class Project < ActiveRecord::Base
status.zero? status.zero?
end end
def ensure_dir_exist
gitlab_shell.add_namespace(repository_storage_path, namespace.full_path)
end
def predefined_variables def predefined_variables
[ [
{ key: 'CI_PROJECT_ID', value: id.to_s, public: true }, { key: 'CI_PROJECT_ID', value: id.to_s, public: true },
{ key: 'CI_PROJECT_NAME', value: path, public: true }, { key: 'CI_PROJECT_NAME', value: path, public: true },
{ key: 'CI_PROJECT_PATH', value: path_with_namespace, public: true }, { key: 'CI_PROJECT_PATH', value: full_path, public: true },
{ key: 'CI_PROJECT_PATH_SLUG', value: path_with_namespace.parameterize, public: true }, { key: 'CI_PROJECT_PATH_SLUG', value: full_path.parameterize, public: true },
{ key: 'CI_PROJECT_NAMESPACE', value: namespace.full_path, public: true }, { key: 'CI_PROJECT_NAMESPACE', value: namespace.full_path, public: true },
{ key: 'CI_PROJECT_URL', value: web_url, public: true } { key: 'CI_PROJECT_URL', value: web_url, public: true }
] ]
...@@ -1452,6 +1390,7 @@ class Project < ActiveRecord::Base ...@@ -1452,6 +1390,7 @@ class Project < ActiveRecord::Base
alias_method :name_with_namespace, :full_name alias_method :name_with_namespace, :full_name
alias_method :human_name, :full_name alias_method :human_name, :full_name
# @deprecated cannot remove yet because it has an index with its name in elasticsearch
alias_method :path_with_namespace, :full_path alias_method :path_with_namespace, :full_path
private private
...@@ -1506,7 +1445,7 @@ class Project < ActiveRecord::Base ...@@ -1506,7 +1445,7 @@ class Project < ActiveRecord::Base
def pending_delete_twin def pending_delete_twin
return false unless path return false unless path
Project.pending_delete.find_by_full_path(path_with_namespace) Project.pending_delete.find_by_full_path(full_path)
end end
## ##
......
...@@ -35,9 +35,9 @@ class FlowdockService < Service ...@@ -35,9 +35,9 @@ class FlowdockService < Service
data[:after], data[:after],
token: token, token: token,
repo: project.repository.path_to_repo, repo: project.repository.path_to_repo,
repo_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}", repo_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}",
commit_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/%s", commit_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/%s",
diff_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/compare/%s...%s" diff_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/compare/%s...%s"
) )
end end
end end
...@@ -140,7 +140,7 @@ class JiraService < IssueTrackerService ...@@ -140,7 +140,7 @@ class JiraService < IssueTrackerService
url: resource_url(user_path(author)) url: resource_url(user_path(author))
}, },
project: { project: {
name: project.path_with_namespace, name: project.full_path,
url: resource_url(namespace_project_path(project.namespace, project)) # rubocop:disable Cop/ProjectPathHelper url: resource_url(namespace_project_path(project.namespace, project)) # rubocop:disable Cop/ProjectPathHelper
}, },
entity: { entity: {
......
class ProjectWiki class ProjectWiki
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
include Storage::LegacyProjectWiki
MARKUPS = { MARKUPS = {
'Markdown' => :markdown, 'Markdown' => :markdown,
...@@ -26,16 +27,19 @@ class ProjectWiki ...@@ -26,16 +27,19 @@ class ProjectWiki
@project.path + '.wiki' @project.path + '.wiki'
end end
def path_with_namespace def full_path
@project.path_with_namespace + ".wiki" @project.full_path + '.wiki'
end end
# @deprecated use full_path when you need it for an URL route or disk_path when you want to point to the filesystem
alias_method :path_with_namespace, :full_path
def web_url def web_url
Gitlab::Routing.url_helpers.project_wiki_url(@project, :home) Gitlab::Routing.url_helpers.project_wiki_url(@project, :home)
end end
def url_to_repo def url_to_repo
gitlab_shell.url_to_repo(path_with_namespace) gitlab_shell.url_to_repo(full_path)
end end
def ssh_url_to_repo def ssh_url_to_repo
...@@ -43,11 +47,11 @@ class ProjectWiki ...@@ -43,11 +47,11 @@ class ProjectWiki
end end
def http_url_to_repo def http_url_to_repo
"#{Gitlab.config.gitlab.url}/#{path_with_namespace}.git" "#{Gitlab.config.gitlab.url}/#{full_path}.git"
end end
def wiki_base_path def wiki_base_path
[Gitlab.config.gitlab.relative_url_root, "/", @project.path_with_namespace, "/wikis"].join('') [Gitlab.config.gitlab.relative_url_root, '/', @project.full_path, '/wikis'].join('')
end end
# Returns the Gollum::Wiki object. # Returns the Gollum::Wiki object.
...@@ -134,7 +138,7 @@ class ProjectWiki ...@@ -134,7 +138,7 @@ class ProjectWiki
end end
def repository def repository
@repository ||= Repository.new(path_with_namespace, @project) @repository ||= Repository.new(full_path, @project, disk_path: disk_path)
end end
def default_branch def default_branch
...@@ -142,7 +146,7 @@ class ProjectWiki ...@@ -142,7 +146,7 @@ class ProjectWiki
end end
def create_repo! def create_repo!
if init_repo(path_with_namespace) if init_repo(disk_path)
wiki = Gollum::Wiki.new(path_to_repo) wiki = Gollum::Wiki.new(path_to_repo)
else else
raise CouldNotCreateWikiError raise CouldNotCreateWikiError
...@@ -162,15 +166,15 @@ class ProjectWiki ...@@ -162,15 +166,15 @@ class ProjectWiki
web_url: web_url, web_url: web_url,
git_ssh_url: ssh_url_to_repo, git_ssh_url: ssh_url_to_repo,
git_http_url: http_url_to_repo, git_http_url: http_url_to_repo,
path_with_namespace: path_with_namespace, path_with_namespace: full_path,
default_branch: default_branch default_branch: default_branch
} }
end end
private private
def init_repo(path_with_namespace) def init_repo(disk_path)
gitlab_shell.add_repository(project.repository_storage_path, path_with_namespace) gitlab_shell.add_repository(project.repository_storage_path, disk_path)
end end
def commit_details(action, message = nil, title = nil) def commit_details(action, message = nil, title = nil)
...@@ -184,7 +188,7 @@ class ProjectWiki ...@@ -184,7 +188,7 @@ class ProjectWiki
end end
def path_to_repo def path_to_repo
@path_to_repo ||= File.join(project.repository_storage_path, "#{path_with_namespace}.git") @path_to_repo ||= File.join(project.repository_storage_path, "#{disk_path}.git")
end end
def update_project_activity def update_project_activity
......
...@@ -4,7 +4,7 @@ class Repository ...@@ -4,7 +4,7 @@ class Repository
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
include RepositoryMirroring include RepositoryMirroring
attr_accessor :path_with_namespace, :project attr_accessor :full_path, :disk_path, :project
delegate :ref_name_for_sha, to: :raw_repository delegate :ref_name_for_sha, to: :raw_repository
...@@ -52,13 +52,14 @@ class Repository ...@@ -52,13 +52,14 @@ class Repository
end end
end end
def initialize(path_with_namespace, project) def initialize(full_path, project, disk_path: nil)
@path_with_namespace = path_with_namespace @full_path = full_path
@disk_path = disk_path || full_path
@project = project @project = project
end end
def raw_repository def raw_repository
return nil unless path_with_namespace return nil unless full_path
@raw_repository ||= initialize_raw_repository @raw_repository ||= initialize_raw_repository
end end
...@@ -66,7 +67,7 @@ class Repository ...@@ -66,7 +67,7 @@ class Repository
# Return absolute path to repository # Return absolute path to repository
def path_to_repo def path_to_repo
@path_to_repo ||= File.expand_path( @path_to_repo ||= File.expand_path(
File.join(repository_storage_path, path_with_namespace + ".git") File.join(repository_storage_path, disk_path + '.git')
) )
end end
...@@ -469,7 +470,7 @@ class Repository ...@@ -469,7 +470,7 @@ class Repository
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/314 # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/314
def exists? def exists?
return false unless path_with_namespace return false unless full_path
Gitlab::GitalyClient.migrate(:repository_exists) do |enabled| Gitlab::GitalyClient.migrate(:repository_exists) do |enabled|
if enabled if enabled
...@@ -1005,7 +1006,7 @@ class Repository ...@@ -1005,7 +1006,7 @@ class Repository
end end
def fetch_remote(remote, forced: false, no_tags: false) def fetch_remote(remote, forced: false, no_tags: false)
gitlab_shell.fetch_remote(repository_storage_path, path_with_namespace, remote, forced: forced, no_tags: no_tags) gitlab_shell.fetch_remote(repository_storage_path, disk_path, remote, forced: forced, no_tags: no_tags)
end end
def fetch_ref(source_path, source_ref, target_ref) def fetch_ref(source_path, source_ref, target_ref)
...@@ -1104,7 +1105,8 @@ class Repository ...@@ -1104,7 +1105,8 @@ class Repository
end end
def cache def cache
@cache ||= RepositoryCache.new(path_with_namespace, @project.id) # TODO: should we use UUIDs here? We could move repositories without clearing this cache
@cache ||= RepositoryCache.new(full_path, @project.id)
end end
def tags_sorted_by_committed_date def tags_sorted_by_committed_date
...@@ -1127,7 +1129,7 @@ class Repository ...@@ -1127,7 +1129,7 @@ class Repository
end end
def repository_event(event, tags = {}) def repository_event(event, tags = {})
Gitlab::Metrics.add_event(event, { path: path_with_namespace }.merge(tags)) Gitlab::Metrics.add_event(event, { path: full_path }.merge(tags))
end end
def create_commit(params = {}) def create_commit(params = {})
...@@ -1141,6 +1143,6 @@ class Repository ...@@ -1141,6 +1143,6 @@ class Repository
end end
def initialize_raw_repository def initialize_raw_repository
Gitlab::Git::Repository.new(project.repository_storage, path_with_namespace + '.git') Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git')
end end
end end
...@@ -60,7 +60,7 @@ class GitOperationService ...@@ -60,7 +60,7 @@ class GitOperationService
start_branch_name = nil if start_repository.empty_repo? start_branch_name = nil if start_repository.empty_repo?
if start_branch_name && !start_repository.branch_exists?(start_branch_name) if start_branch_name && !start_repository.branch_exists?(start_branch_name)
raise ArgumentError, "Cannot find branch #{start_branch_name} in #{start_repository.path_with_namespace}" raise ArgumentError, "Cannot find branch #{start_branch_name} in #{start_repository.full_path}"
end end
update_branch_with_hooks(branch_name) do update_branch_with_hooks(branch_name) do
......
...@@ -9,7 +9,7 @@ module Projects ...@@ -9,7 +9,7 @@ module Projects
def async_execute def async_execute
project.update_attribute(:pending_delete, true) project.update_attribute(:pending_delete, true)
job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params) job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params)
Rails.logger.info("User #{current_user.id} scheduled destruction of project #{project.path_with_namespace} with job ID #{job_id}") Rails.logger.info("User #{current_user.id} scheduled destruction of project #{project.full_path} with job ID #{job_id}")
end end
def execute def execute
...@@ -40,7 +40,7 @@ module Projects ...@@ -40,7 +40,7 @@ module Projects
private private
def repo_path def repo_path
project.path_with_namespace project.disk_path
end end
def wiki_path def wiki_path
...@@ -127,7 +127,7 @@ module Projects ...@@ -127,7 +127,7 @@ module Projects
def flush_caches(project) def flush_caches(project)
project.repository.before_delete project.repository.before_delete
Repository.new(wiki_path, project).before_delete Repository.new(wiki_path, project, disk_path: repo_path).before_delete
end end
end end
end end
...@@ -2,7 +2,7 @@ module Projects ...@@ -2,7 +2,7 @@ module Projects
module ImportExport module ImportExport
class ExportService < BaseService class ExportService < BaseService
def execute(_options = {}) def execute(_options = {})
@shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(project.path_with_namespace, 'work')) @shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(project.disk_path, 'work'))
save_all save_all
end end
......
...@@ -11,7 +11,7 @@ module Projects ...@@ -11,7 +11,7 @@ module Projects
success success
rescue => e rescue => e
error("Error importing repository #{project.import_url} into #{project.path_with_namespace} - #{e.message}") error("Error importing repository #{project.import_url} into #{project.full_path} - #{e.message}")
end end
private private
...@@ -51,7 +51,7 @@ module Projects ...@@ -51,7 +51,7 @@ module Projects
end end
def clone_repository def clone_repository
gitlab_shell.import_repository(project.repository_storage_path, project.path_with_namespace, project.import_url) gitlab_shell.import_repository(project.repository_storage_path, project.disk_path, project.import_url)
end end
def fetch_repository def fetch_repository
......
...@@ -34,7 +34,7 @@ module Projects ...@@ -34,7 +34,7 @@ module Projects
private private
def transfer(project) def transfer(project)
@old_path = project.path_with_namespace @old_path = project.full_path
@old_group = project.group @old_group = project.group
@new_path = File.join(@new_namespace.try(:full_path) || '', project.path) @new_path = File.join(@new_namespace.try(:full_path) || '', project.path)
@old_namespace = project.namespace @old_namespace = project.namespace
...@@ -61,11 +61,13 @@ module Projects ...@@ -61,11 +61,13 @@ module Projects
project.send_move_instructions(@old_path) project.send_move_instructions(@old_path)
# Move main repository # Move main repository
# TODO: check storage type and NOOP when not using Legacy
unless move_repo_folder(@old_path, @new_path) unless move_repo_folder(@old_path, @new_path)
raise TransferError.new('Cannot move project') raise TransferError.new('Cannot move project')
end end
# Move wiki repo also if present # Move wiki repo also if present
# TODO: check storage type and NOOP when not using Legacy
move_repo_folder("#{@old_path}.wiki", "#{@new_path}.wiki") move_repo_folder("#{@old_path}.wiki", "#{@new_path}.wiki")
# Move missing group labels to project # Move missing group labels to project
......
...@@ -24,7 +24,7 @@ class SystemHooksService ...@@ -24,7 +24,7 @@ class SystemHooksService
key: model.key, key: model.key,
id: model.id id: model.id
) )
if model.user if model.user
data[:username] = model.user.username data[:username] = model.user.username
end end
...@@ -56,7 +56,7 @@ class SystemHooksService ...@@ -56,7 +56,7 @@ class SystemHooksService
when GroupMember when GroupMember
data.merge!(group_member_data(model)) data.merge!(group_member_data(model))
end end
data data
end end
...@@ -79,7 +79,7 @@ class SystemHooksService ...@@ -79,7 +79,7 @@ class SystemHooksService
{ {
name: model.name, name: model.name,
path: model.path, path: model.path,
path_with_namespace: model.path_with_namespace, path_with_namespace: model.full_path,
project_id: model.id, project_id: model.id,
owner_name: owner.name, owner_name: owner.name,
owner_email: owner.respond_to?(:email) ? owner.email : "", owner_email: owner.respond_to?(:email) ? owner.email : "",
...@@ -93,7 +93,7 @@ class SystemHooksService ...@@ -93,7 +93,7 @@ class SystemHooksService
{ {
project_name: project.name, project_name: project.name,
project_path: project.path, project_path: project.path,
project_path_with_namespace: project.path_with_namespace, project_path_with_namespace: project.full_path,
project_id: project.id, project_id: project.id,
user_username: model.user.username, user_username: model.user.username,
user_name: model.user.name, user_name: model.user.name,
......
...@@ -30,7 +30,7 @@ class FileUploader < GitlabUploader ...@@ -30,7 +30,7 @@ class FileUploader < GitlabUploader
# #
# Returns a String without a trailing slash # Returns a String without a trailing slash
def self.dynamic_path_segment(model) def self.dynamic_path_segment(model)
File.join(CarrierWave.root, base_dir, model.path_with_namespace) File.join(CarrierWave.root, base_dir, model.full_path)
end end
attr_accessor :model attr_accessor :model
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
%span.badge %span.badge
= storage_counter(project.statistics.storage_size) = storage_counter(project.statistics.storage_size)
%span.pull-right.light %span.pull-right.light
%span.monospace= project.path_with_namespace + ".git" %span.monospace= project.full_path + '.git'
.panel-footer .panel-footer
= paginate @projects, param_name: 'projects_page', theme: 'gitlab' = paginate @projects, param_name: 'projects_page', theme: 'gitlab'
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
%span.badge %span.badge
= storage_counter(project.statistics.storage_size) = storage_counter(project.statistics.storage_size)
%span.pull-right.light %span.pull-right.light
%span.monospace= project.path_with_namespace + ".git" %span.monospace= project.full_path + '.git'
.col-md-6 .col-md-6
- if can?(current_user, :admin_group_member, @group) - if can?(current_user, :admin_group_member, @group)
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
%td %td
= provider_project_link(provider, project.import_source) = provider_project_link(provider, project.import_source)
%td %td
= link_to project.path_with_namespace, [project.namespace.becomes(Namespace), project] = link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status %td.job-status
- if project.import_status == 'finished' - if project.import_status == 'finished'
%span %span
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
job.attr("id", "project_#{@project.id}") job.attr("id", "project_#{@project.id}")
target_field = job.find(".import-target") target_field = job.find(".import-target")
target_field.empty() target_field.empty()
target_field.append('#{link_to @project.path_with_namespace, project_path(@project)}') target_field.append('#{link_to @project.full_path, project_path(@project)}')
$("table.import-jobs tbody").prepend(job) $("table.import-jobs tbody").prepend(job)
job.addClass("active").find(".import-actions").html("<i class='fa fa-spinner fa-spin'></i> started") job.addClass("active").find(".import-actions").html("<i class='fa fa-spinner fa-spin'></i> started")
- else - else
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
%td %td
= link_to project.import_source, "https://bitbucket.org/#{project.import_source}", target: '_blank', rel: 'noopener noreferrer' = link_to project.import_source, "https://bitbucket.org/#{project.import_source}", target: '_blank', rel: 'noopener noreferrer'
%td %td
= link_to project.path_with_namespace, [project.namespace.becomes(Namespace), project] = link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status %td.job-status
- if project.import_status == 'finished' - if project.import_status == 'finished'
%span %span
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
%td %td
= project.import_source = project.import_source
%td %td
= link_to project.path_with_namespace, [project.namespace.becomes(Namespace), project] = link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status %td.job-status
- if project.import_status == 'finished' - if project.import_status == 'finished'
%span %span
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
%td %td
= link_to project.import_source, "https://gitlab.com/#{project.import_source}", target: "_blank" = link_to project.import_source, "https://gitlab.com/#{project.import_source}", target: "_blank"
%td %td
= link_to project.path_with_namespace, [project.namespace.becomes(Namespace), project] = link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status %td.job-status
- if project.import_status == 'finished' - if project.import_status == 'finished'
%span %span
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
%td %td
= link_to project.import_source, "https://code.google.com/p/#{project.import_source}", target: "_blank", rel: 'noopener noreferrer' = link_to project.import_source, "https://code.google.com/p/#{project.import_source}", target: "_blank", rel: 'noopener noreferrer'
%td %td
= link_to project.path_with_namespace, [project.namespace.becomes(Namespace), project] = link_to project.full_path, [project.namespace.becomes(Namespace), project]
%td.job-status %td.job-status
- if project.import_status == 'finished' - if project.import_status == 'finished'
%span %span
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- notes = commit.notes - notes = commit.notes
- note_count = notes.user.count - note_count = notes.user.count
- cache_key = [project.path_with_namespace, commit.id, current_application_settings, note_count, @path.presence, current_controller?(:commits)] - cache_key = [project.full_path, commit.id, current_application_settings, note_count, @path.presence, current_controller?(:commits)]
- cache_key.push(commit.status(ref)) if commit.status(ref) - cache_key.push(commit.status(ref)) if commit.status(ref)
= cache(cache_key, expires_in: 1.day) do = cache(cache_key, expires_in: 1.day) do
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
Suggestions: Suggestions:
%code= 'gitlab' %code= 'gitlab'
%code= @project.path # Path contains no spaces, but dashes %code= @project.path # Path contains no spaces, but dashes
%code= @project.path_with_namespace %code= @project.full_path
%p %p
Reserved: Reserved:
= link_to 'https://docs.mattermost.com/help/messaging/executing-commands.html#built-in-commands', target: '__blank' do = link_to 'https://docs.mattermost.com/help/messaging/executing-commands.html#built-in-commands', target: '__blank' do
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
- projects = target_projects(@project) - projects = target_projects(@project)
.merge-request-select.dropdown .merge-request-select.dropdown
= f.hidden_field :target_project_id = f.hidden_field :target_project_id
= dropdown_toggle f.object.target_project.path_with_namespace, { toggle: "dropdown", field_name: "#{f.object_name}[target_project_id]", disabled: @merge_request.persisted? }, { toggle_class: "js-compare-dropdown js-target-project" } = dropdown_toggle f.object.target_project.full_path, { toggle: "dropdown", field_name: "#{f.object_name}[target_project_id]", disabled: @merge_request.persisted? }, { toggle_class: "js-compare-dropdown js-target-project" }
.dropdown-menu.dropdown-menu-selectable.dropdown-target-project .dropdown-menu.dropdown-menu-selectable.dropdown-target-project
= dropdown_title("Select target project") = dropdown_title("Select target project")
= dropdown_filter("Search projects") = dropdown_filter("Search projects")
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
- projects.each do |project| - projects.each do |project|
%li %li
%a{ href: "#", class: "#{('is-active' if selected == project.id)}", data: { id: project.id } } %a{ href: "#", class: "#{('is-active' if selected == project.id)}", data: { id: project.id } }
= project.path_with_namespace = project.full_path
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
Suggestions: Suggestions:
%code= 'gitlab' %code= 'gitlab'
%code= @project.path # Path contains no spaces, but dashes %code= @project.path # Path contains no spaces, but dashes
%code= @project.path_with_namespace %code= @project.full_path
.form-group .form-group
= label_tag :request_url, 'Request URL', class: 'col-sm-2 col-xs-12 control-label' = label_tag :request_url, 'Request URL', class: 'col-sm-2 col-xs-12 control-label'
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
Suggestions: Suggestions:
%code= 'gitlab' %code= 'gitlab'
%code= @project.path # Path contains no spaces, but dashes %code= @project.path # Path contains no spaces, but dashes
%code= @project.path_with_namespace %code= @project.full_path
.form-group .form-group
= label_tag :url, 'URL', class: 'col-sm-2 col-xs-12 control-label' = label_tag :url, 'URL', class: 'col-sm-2 col-xs-12 control-label'
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
.git-access-header .git-access-header
Clone repository Clone repository
%strong= @project_wiki.path_with_namespace %strong= @project_wiki.full_path
= render "shared/clone_panel", project: @project_wiki = render "shared/clone_panel", project: @project_wiki
......
...@@ -66,7 +66,7 @@ class IrkerWorker ...@@ -66,7 +66,7 @@ class IrkerWorker
end end
def send_new_branch(project, repo_name, committer, branch) def send_new_branch(project, repo_name, committer, branch)
repo_path = project.path_with_namespace repo_path = project.full_path
newbranch = "#{Gitlab.config.gitlab.url}/#{repo_path}/branches" newbranch = "#{Gitlab.config.gitlab.url}/#{repo_path}/branches"
newbranch = "\x0302\x1f#{newbranch}\x0f" if @colors newbranch = "\x0302\x1f#{newbranch}\x0f" if @colors
...@@ -109,7 +109,7 @@ class IrkerWorker ...@@ -109,7 +109,7 @@ class IrkerWorker
end end
def send_commits_count(data, project, repo, committer, branch) def send_commits_count(data, project, repo, committer, branch)
url = compare_url data, project.path_with_namespace url = compare_url data, project.full_path
commits = colorize_commits data['total_commits_count'] commits = colorize_commits data['total_commits_count']
new_commits = 'new commit' new_commits = 'new commit'
......
...@@ -16,7 +16,7 @@ class RepositoryImportWorker ...@@ -16,7 +16,7 @@ class RepositoryImportWorker
Gitlab::Metrics.add_event(:import_repository, Gitlab::Metrics.add_event(:import_repository,
import_url: @project.import_url, import_url: @project.import_url,
path: @project.path_with_namespace) path: @project.full_path)
project.update_columns(import_jid: self.jid, import_error: nil) project.update_columns(import_jid: self.jid, import_error: nil)
......
...@@ -16,6 +16,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration ...@@ -16,6 +16,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration
end end
def repository_path def repository_path
# TODO: review if the change from Legacy storage needs to reflect here as well.
File.join(repository_storage_path, read_attribute(:path_with_namespace) + '.git') File.join(repository_storage_path, read_attribute(:path_with_namespace) + '.git')
end end
......
...@@ -30,8 +30,8 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -30,8 +30,8 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
expect(@merge_request.source_project).to eq @forked_project expect(@merge_request.source_project).to eq @forked_project
expect(@merge_request.source_branch).to eq "fix" expect(@merge_request.source_branch).to eq "fix"
expect(@merge_request.target_branch).to eq "master" expect(@merge_request.target_branch).to eq "master"
expect(page).to have_content @forked_project.path_with_namespace expect(page).to have_content @forked_project.full_path
expect(page).to have_content @project.path_with_namespace expect(page).to have_content @project.full_path
expect(page).to have_content @merge_request.source_branch expect(page).to have_content @merge_request.source_branch
expect(page).to have_content @merge_request.target_branch expect(page).to have_content @merge_request.target_branch
...@@ -43,10 +43,10 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -43,10 +43,10 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
expect(page).to have_content('Target branch') expect(page).to have_content('Target branch')
first('.js-source-project').click first('.js-source-project').click
first('.dropdown-source-project a', text: @forked_project.path_with_namespace) first('.dropdown-source-project a', text: @forked_project.full_path)
first('.js-target-project').click first('.js-target-project').click
first('.dropdown-target-project a', text: @project.path_with_namespace) first('.dropdown-target-project a', text: @project.full_path)
first('.js-source-branch').click first('.js-source-branch').click
wait_for_requests wait_for_requests
...@@ -81,8 +81,8 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -81,8 +81,8 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
expect(@merge_request.source_project).to eq @forked_project expect(@merge_request.source_project).to eq @forked_project
expect(@merge_request.source_branch).to eq "fix" expect(@merge_request.source_branch).to eq "fix"
expect(@merge_request.target_branch).to eq "master" expect(@merge_request.target_branch).to eq "master"
expect(page).to have_content @forked_project.path_with_namespace expect(page).to have_content @forked_project.full_path
expect(page).to have_content @project.path_with_namespace expect(page).to have_content @project.full_path
expect(page).to have_content @merge_request.source_branch expect(page).to have_content @merge_request.source_branch
expect(page).to have_content @merge_request.target_branch expect(page).to have_content @merge_request.target_branch
end end
......
...@@ -47,7 +47,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps ...@@ -47,7 +47,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
step 'I should be redirected to "Community" page' do step 'I should be redirected to "Community" page' do
project = Project.find_by(name: 'Community') project = Project.find_by(name: 'Community')
expect(current_path).to eq "/#{project.path_with_namespace}" expect(current_path).to eq "/#{project.full_path}"
expect(status_code).to eq 200 expect(status_code).to eq 200
end end
...@@ -61,7 +61,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps ...@@ -61,7 +61,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
step 'I should be redirected to "Enterprise" page' do step 'I should be redirected to "Enterprise" page' do
project = Project.find_by(name: 'Enterprise') project = Project.find_by(name: 'Enterprise')
expect(current_path).to eq "/#{project.path_with_namespace}" expect(current_path).to eq "/#{project.full_path}"
expect(status_code).to eq 200 expect(status_code).to eq 200
end end
end end
...@@ -142,7 +142,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps ...@@ -142,7 +142,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
end end
step 'I should see non-escaped link in the pages list' do step 'I should see non-escaped link in the pages list' do
expect(page).to have_xpath("//a[@href='/#{project.path_with_namespace}/wikis/one/two/three-test']") expect(page).to have_xpath("//a[@href='/#{project.full_path}/wikis/one/two/three-test']")
end end
step 'I edit the Wiki page with a path' do step 'I edit the Wiki page with a path' do
......
...@@ -90,7 +90,7 @@ module API ...@@ -90,7 +90,7 @@ module API
if result.valid? if result.valid?
if result.build if result.build
Gitlab::Metrics.add_event(:build_found, Gitlab::Metrics.add_event(:build_found,
project: result.build.project.path_with_namespace) project: result.build.project.full_path)
present result.build, with: Entities::JobRequest::Response present result.build, with: Entities::JobRequest::Response
else else
Gitlab::Metrics.add_event(:build_not_found) Gitlab::Metrics.add_event(:build_not_found)
...@@ -119,7 +119,7 @@ module API ...@@ -119,7 +119,7 @@ module API
job.trace.set(params[:trace]) if params[:trace] job.trace.set(params[:trace]) if params[:trace]
Gitlab::Metrics.add_event(:update_build, Gitlab::Metrics.add_event(:update_build,
project: job.project.path_with_namespace) project: job.project.full_path)
case params[:state].to_s case params[:state].to_s
when 'success' when 'success'
......
...@@ -7,7 +7,7 @@ module Backup ...@@ -7,7 +7,7 @@ module Backup
prepare prepare
Project.find_each(batch_size: 1000) do |project| Project.find_each(batch_size: 1000) do |project|
progress.print " * #{project.path_with_namespace} ... " progress.print " * #{project.full_path} ... "
path_to_project_repo = path_to_repo(project) path_to_project_repo = path_to_repo(project)
path_to_project_bundle = path_to_bundle(project) path_to_project_bundle = path_to_bundle(project)
...@@ -42,7 +42,7 @@ module Backup ...@@ -42,7 +42,7 @@ module Backup
path_to_wiki_bundle = path_to_bundle(wiki) path_to_wiki_bundle = path_to_bundle(wiki)
if File.exist?(path_to_wiki_repo) if File.exist?(path_to_wiki_repo)
progress.print " * #{wiki.path_with_namespace} ... " progress.print " * #{wiki.full_path} ... "
if empty_repo?(wiki) if empty_repo?(wiki)
progress.puts " [SKIPPED]".color(:cyan) progress.puts " [SKIPPED]".color(:cyan)
else else
...@@ -71,11 +71,11 @@ module Backup ...@@ -71,11 +71,11 @@ module Backup
end end
Project.find_each(batch_size: 1000) do |project| Project.find_each(batch_size: 1000) do |project|
progress.print " * #{project.path_with_namespace} ... " progress.print " * #{project.full_path} ... "
path_to_project_repo = path_to_repo(project) path_to_project_repo = path_to_repo(project)
path_to_project_bundle = path_to_bundle(project) path_to_project_bundle = path_to_bundle(project)
project.ensure_dir_exist project.ensure_storage_path_exist
cmd = if File.exist?(path_to_project_bundle) cmd = if File.exist?(path_to_project_bundle)
%W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_project_bundle} #{path_to_project_repo}) %W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_project_bundle} #{path_to_project_repo})
...@@ -104,7 +104,7 @@ module Backup ...@@ -104,7 +104,7 @@ module Backup
path_to_wiki_bundle = path_to_bundle(wiki) path_to_wiki_bundle = path_to_bundle(wiki)
if File.exist?(path_to_wiki_bundle) if File.exist?(path_to_wiki_bundle)
progress.print " * #{wiki.path_with_namespace} ... " progress.print " * #{wiki.full_path} ... "
# If a wiki bundle exists, first remove the empty repo # If a wiki bundle exists, first remove the empty repo
# that was initialized with ProjectWiki.new() and then # that was initialized with ProjectWiki.new() and then
...@@ -142,11 +142,11 @@ module Backup ...@@ -142,11 +142,11 @@ module Backup
end end
def path_to_bundle(project) def path_to_bundle(project)
File.join(backup_repos_path, project.path_with_namespace + '.bundle') File.join(backup_repos_path, project.disk_path + '.bundle')
end end
def path_to_tars(project, dir = nil) def path_to_tars(project, dir = nil)
path = File.join(backup_repos_path, project.path_with_namespace) path = File.join(backup_repos_path, project.disk_path)
if dir if dir
File.join(path, "#{dir}.tar") File.join(path, "#{dir}.tar")
...@@ -185,14 +185,14 @@ module Backup ...@@ -185,14 +185,14 @@ module Backup
def progress_warn(project, cmd, output) def progress_warn(project, cmd, output)
progress.puts "[WARNING] Executing #{cmd}".color(:orange) progress.puts "[WARNING] Executing #{cmd}".color(:orange)
progress.puts "Ignoring error on #{project.path_with_namespace} - #{output}".color(:orange) progress.puts "Ignoring error on #{project.full_path} - #{output}".color(:orange)
end end
def empty_repo?(project_or_wiki) def empty_repo?(project_or_wiki)
project_or_wiki.repository.expire_exists_cache # protect backups from stale cache project_or_wiki.repository.expire_exists_cache # protect backups from stale cache
project_or_wiki.repository.empty_repo? project_or_wiki.repository.empty_repo?
rescue => e rescue => e
progress.puts "Ignoring repository error and continuing backing up project: #{project_or_wiki.path_with_namespace} - #{e.message}".color(:orange) progress.puts "Ignoring repository error and continuing backing up project: #{project_or_wiki.full_path} - #{e.message}".color(:orange)
false false
end end
......
...@@ -259,7 +259,7 @@ module Banzai ...@@ -259,7 +259,7 @@ module Banzai
found = [] found = []
projects.each do |project| projects.each do |project|
ref = project.path_with_namespace ref = project.full_path
get_or_set_cache(cache, ref) { project } get_or_set_cache(cache, ref) { project }
found << ref found << ref
end end
...@@ -277,7 +277,7 @@ module Banzai ...@@ -277,7 +277,7 @@ module Banzai
end end
def current_project_path def current_project_path
@current_project_path ||= project.path_with_namespace @current_project_path ||= project.full_path
end end
def current_project_namespace_path def current_project_namespace_path
......
...@@ -51,7 +51,7 @@ module Banzai ...@@ -51,7 +51,7 @@ module Banzai
uri.path = [ uri.path = [
relative_url_root, relative_url_root,
context[:project].path_with_namespace, context[:project].full_path,
uri_type(file_path), uri_type(file_path),
Addressable::URI.escape(ref), Addressable::URI.escape(ref),
Addressable::URI.escape(file_path) Addressable::URI.escape(file_path)
......
...@@ -28,7 +28,7 @@ module Banzai ...@@ -28,7 +28,7 @@ module Banzai
end end
def build_url(uri) def build_url(uri)
File.join(Gitlab.config.gitlab.url, project.path_with_namespace, uri) File.join(Gitlab.config.gitlab.url, project.full_path, uri)
end end
def project def project
......
...@@ -29,7 +29,7 @@ module Ci ...@@ -29,7 +29,7 @@ module Ci
if result.valid? if result.valid?
if result.build if result.build
Gitlab::Metrics.add_event(:build_found, Gitlab::Metrics.add_event(:build_found,
project: result.build.project.path_with_namespace) project: result.build.project.full_path)
present result.build, with: Entities::BuildDetails present result.build, with: Entities::BuildDetails
else else
...@@ -64,7 +64,7 @@ module Ci ...@@ -64,7 +64,7 @@ module Ci
build.trace.set(params[:trace]) if params[:trace] build.trace.set(params[:trace]) if params[:trace]
Gitlab::Metrics.add_event(:update_build, Gitlab::Metrics.add_event(:update_build,
project: build.project.path_with_namespace) project: build.project.full_path)
case params[:state].to_s case params[:state].to_s
when 'success' when 'success'
......
...@@ -93,7 +93,7 @@ module Github ...@@ -93,7 +93,7 @@ module Github
def fetch_wiki_repository def fetch_wiki_repository
wiki_url = "https://#{options.fetch(:token)}@github.com/#{repo}.wiki.git" wiki_url = "https://#{options.fetch(:token)}@github.com/#{repo}.wiki.git"
wiki_path = "#{project.path_with_namespace}.wiki" wiki_path = "#{project.full_path}.wiki"
unless project.wiki.repository_exists? unless project.wiki.repository_exists?
gitlab_shell.import_repository(project.repository_storage_path, wiki_path, wiki_url) gitlab_shell.import_repository(project.repository_storage_path, wiki_path, wiki_url)
......
...@@ -61,7 +61,7 @@ module Gitlab ...@@ -61,7 +61,7 @@ module Gitlab
def import_wiki def import_wiki
return if project.wiki.repository_exists? return if project.wiki.repository_exists?
path_with_namespace = "#{project.path_with_namespace}.wiki" path_with_namespace = "#{project.full_path}.wiki"
import_url = project.import_url.sub(/\.git\z/, ".git/wiki") import_url = project.import_url.sub(/\.git\z/, ".git/wiki")
gitlab_shell.import_repository(project.repository_storage_path, path_with_namespace, import_url) gitlab_shell.import_repository(project.repository_storage_path, path_with_namespace, import_url)
rescue StandardError => e rescue StandardError => e
......
...@@ -117,7 +117,7 @@ module Gitlab ...@@ -117,7 +117,7 @@ module Gitlab
def subject def subject
subject_text = '[Git]' subject_text = '[Git]'
subject_text << "[#{project.path_with_namespace}]" subject_text << "[#{project.full_path}]"
subject_text << "[#{ref_name}]" if @action == :push subject_text << "[#{ref_name}]" if @action == :push
subject_text << ' ' subject_text << ' '
......
...@@ -254,7 +254,7 @@ module Gitlab ...@@ -254,7 +254,7 @@ module Gitlab
def import_wiki def import_wiki
unless project.wiki.repository_exists? unless project.wiki.repository_exists?
wiki = WikiFormatter.new(project) wiki = WikiFormatter.new(project)
gitlab_shell.import_repository(project.repository_storage_path, wiki.path_with_namespace, wiki.import_url) gitlab_shell.import_repository(project.repository_storage_path, wiki.disk_path, wiki.import_url)
end end
rescue Gitlab::Shell::Error => e rescue Gitlab::Shell::Error => e
# GitHub error message when the wiki repo has not been created, # GitHub error message when the wiki repo has not been created,
......
...@@ -7,8 +7,8 @@ module Gitlab ...@@ -7,8 +7,8 @@ module Gitlab
@project = project @project = project
end end
def path_with_namespace def disk_path
"#{project.path_with_namespace}.wiki" "#{project.disk_path}.wiki"
end end
def import_url def import_url
......
...@@ -13,7 +13,7 @@ module Gitlab ...@@ -13,7 +13,7 @@ module Gitlab
def restore def restore
return true unless File.exist?(@path_to_bundle) return true unless File.exist?(@path_to_bundle)
gitlab_shell.import_repository(@project.repository_storage_path, @project.path_with_namespace, @path_to_bundle) gitlab_shell.import_repository(@project.repository_storage_path, @project.disk_path, @path_to_bundle)
rescue => e rescue => e
@shared.error(e) @shared.error(e)
false false
......
...@@ -24,6 +24,7 @@ module Gitlab ...@@ -24,6 +24,7 @@ module Gitlab
end end
def uploads_path def uploads_path
# TODO: decide what to do with uploads. We will use UUIDs here too?
File.join(Rails.root.join('public/uploads'), @project.path_with_namespace) File.join(Rails.root.join('public/uploads'), @project.path_with_namespace)
end end
end end
......
...@@ -527,7 +527,7 @@ namespace :gitlab do ...@@ -527,7 +527,7 @@ namespace :gitlab do
repo_dirs = user.authorized_projects.map do |p| repo_dirs = user.authorized_projects.map do |p|
File.join( File.join(
p.repository_storage_path, p.repository_storage_path,
"#{p.path_with_namespace}.git" "#{p.disk_path}.git"
) )
end end
......
...@@ -9,7 +9,7 @@ namespace :gitlab do ...@@ -9,7 +9,7 @@ namespace :gitlab do
scope = scope.where('id IN (?) OR namespace_id in (?)', project_ids, namespace_ids) scope = scope.where('id IN (?) OR namespace_id in (?)', project_ids, namespace_ids)
end end
scope.find_each do |project| scope.find_each do |project|
base = File.join(project.repository_storage_path, project.path_with_namespace) base = File.join(project.repository_storage_path, project.disk_path)
puts base + '.git' puts base + '.git'
puts base + '.wiki.git' puts base + '.wiki.git'
end end
......
...@@ -80,7 +80,7 @@ namespace :gitlab do ...@@ -80,7 +80,7 @@ namespace :gitlab do
print '-' print '-'
else else
if Gitlab::Shell.new.add_repository(project.repository_storage_path, if Gitlab::Shell.new.add_repository(project.repository_storage_path,
project.path_with_namespace) project.disk_path)
print '.' print '.'
else else
print 'F' print 'F'
......
...@@ -48,7 +48,7 @@ describe Projects::BlobController do ...@@ -48,7 +48,7 @@ describe Projects::BlobController do
let(:id) { 'markdown/doc' } let(:id) { 'markdown/doc' }
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") .to redirect_to("/#{project.full_path}/tree/markdown/doc")
end end
end end
end end
......
...@@ -33,7 +33,7 @@ describe Projects::BranchesController do ...@@ -33,7 +33,7 @@ describe Projects::BranchesController do
let(:ref) { "master" } let(:ref) { "master" }
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.path_with_namespace}/tree/merge_branch") .to redirect_to("/#{project.full_path}/tree/merge_branch")
end end
end end
...@@ -42,7 +42,7 @@ describe Projects::BranchesController do ...@@ -42,7 +42,7 @@ describe Projects::BranchesController do
let(:ref) { "master" } let(:ref) { "master" }
it 'redirects' do it 'redirects' do
expect(subject) expect(subject)
.to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") .to redirect_to("/#{project.full_path}/tree/alert('merge');")
end end
end end
...@@ -82,7 +82,7 @@ describe Projects::BranchesController do ...@@ -82,7 +82,7 @@ describe Projects::BranchesController do
issue_iid: issue.iid issue_iid: issue.iid
expect(subject) expect(subject)
.to redirect_to("/#{project.path_with_namespace}/tree/1-feature-branch") .to redirect_to("/#{project.full_path}/tree/1-feature-branch")
end end
it 'posts a system note' do it 'posts a system note' do
......
...@@ -609,7 +609,7 @@ describe Projects::MergeRequestsController do ...@@ -609,7 +609,7 @@ describe Projects::MergeRequestsController do
end end
it 'links to the environment on that project' do it 'links to the environment on that project' do
expect(json_response.first['url']).to match /#{forked.path_with_namespace}/ expect(json_response.first['url']).to match /#{forked.full_path}/
end end
end end
end end
......
...@@ -81,7 +81,7 @@ describe Projects::TreeController do ...@@ -81,7 +81,7 @@ describe Projects::TreeController do
context 'redirect to blob' do context 'redirect to blob' do
let(:id) { 'master/README.md' } let(:id) { 'master/README.md' }
it 'redirects' do it 'redirects' do
redirect_url = "/#{project.path_with_namespace}/blob/master/README.md" redirect_url = "/#{project.full_path}/blob/master/README.md"
expect(subject) expect(subject)
.to redirect_to(redirect_url) .to redirect_to(redirect_url)
end end
...@@ -107,7 +107,7 @@ describe Projects::TreeController do ...@@ -107,7 +107,7 @@ describe Projects::TreeController do
it 'redirects to the new directory' do it 'redirects to the new directory' do
expect(subject) expect(subject)
.to redirect_to("/#{project.path_with_namespace}/tree/#{branch_name}/#{path}") .to redirect_to("/#{project.full_path}/tree/#{branch_name}/#{path}")
expect(flash[:notice]).to eq('The directory has been successfully created.') expect(flash[:notice]).to eq('The directory has been successfully created.')
end end
end end
...@@ -118,7 +118,7 @@ describe Projects::TreeController do ...@@ -118,7 +118,7 @@ describe Projects::TreeController do
it 'does not allow overwriting of existing files' do it 'does not allow overwriting of existing files' do
expect(subject) expect(subject)
.to redirect_to("/#{project.path_with_namespace}/tree/master") .to redirect_to("/#{project.full_path}/tree/master")
expect(flash[:alert]).to eq('A file with this name already exists') expect(flash[:alert]).to eq('A file with this name already exists')
end end
end end
......
...@@ -64,7 +64,7 @@ FactoryGirl.define do ...@@ -64,7 +64,7 @@ FactoryGirl.define do
# We delete hooks so that gitlab-shell will not try to authenticate with # We delete hooks so that gitlab-shell will not try to authenticate with
# an API that isn't running # an API that isn't running
FileUtils.rm_r(File.join(project.repository_storage_path, "#{project.path_with_namespace}.git", 'hooks')) FileUtils.rm_r(File.join(project.repository_storage_path, "#{project.disk_path}.git", 'hooks'))
end end
end end
...@@ -72,7 +72,7 @@ FactoryGirl.define do ...@@ -72,7 +72,7 @@ FactoryGirl.define do
after(:create) do |project| after(:create) do |project|
raise "Failed to create repository!" unless project.create_repository raise "Failed to create repository!" unless project.create_repository
FileUtils.rm_r(File.join(project.repository_storage_path, "#{project.path_with_namespace}.git", 'refs')) FileUtils.rm_r(File.join(project.repository_storage_path, "#{project.disk_path}.git", 'refs'))
end end
end end
......
...@@ -67,8 +67,8 @@ feature 'Create New Merge Request', js: true do ...@@ -67,8 +67,8 @@ feature 'Create New Merge Request', js: true do
visit project_new_merge_request_path(project, merge_request: { target_project_id: private_project.id }) visit project_new_merge_request_path(project, merge_request: { target_project_id: private_project.id })
expect(page).not_to have_content private_project.path_with_namespace expect(page).not_to have_content private_project.full_path
expect(page).to have_content project.path_with_namespace expect(page).to have_content project.full_path
end end
end end
...@@ -78,8 +78,8 @@ feature 'Create New Merge Request', js: true do ...@@ -78,8 +78,8 @@ feature 'Create New Merge Request', js: true do
visit project_new_merge_request_path(project, merge_request: { source_project_id: private_project.id }) visit project_new_merge_request_path(project, merge_request: { source_project_id: private_project.id })
expect(page).not_to have_content private_project.path_with_namespace expect(page).not_to have_content private_project.full_path
expect(page).to have_content project.path_with_namespace expect(page).to have_content project.full_path
end end
end end
......
...@@ -38,10 +38,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do ...@@ -38,10 +38,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do
expect(page).to have_content("regular link") expect(page).to have_content("regular link")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/regular\">regular link</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/regular\">regular link</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a/b/relative\">relative link 1</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a/b/relative\">relative link 1</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a/b/c/relative\">relative link 2</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a/b/c/relative\">relative link 2</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a/b/c/e/f/relative\">relative link 3</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a/b/c/e/f/relative\">relative link 3</a>")
end end
end end
...@@ -60,10 +60,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do ...@@ -60,10 +60,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do
expect(page).to have_content("regular link") expect(page).to have_content("regular link")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/regular\">regular link</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/regular\">regular link</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/relative\">relative link 1</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/relative\">relative link 1</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>")
end end
end end
...@@ -82,10 +82,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do ...@@ -82,10 +82,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do
expect(page).to have_content("regular link") expect(page).to have_content("regular link")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/regular\">regular link</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/regular\">regular link</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/relative\">relative link 1</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/relative\">relative link 1</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>")
end end
end end
end end
...@@ -115,10 +115,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do ...@@ -115,10 +115,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do
expect(page).to have_content("regular link") expect(page).to have_content("regular link")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/regular\">regular link</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/regular\">regular link</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a/b/relative\">relative link 1</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a/b/relative\">relative link 1</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a/b/c/relative\">relative link 2</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a/b/c/relative\">relative link 2</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a/b/c/e/f/relative\">relative link 3</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a/b/c/e/f/relative\">relative link 3</a>")
end end
end end
...@@ -132,10 +132,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do ...@@ -132,10 +132,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do
expect(page).to have_content("regular link") expect(page).to have_content("regular link")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/regular\">regular link</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/regular\">regular link</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/relative\">relative link 1</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/relative\">relative link 1</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>")
end end
end end
...@@ -149,10 +149,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do ...@@ -149,10 +149,10 @@ feature 'Projects > Wiki > User previews markdown changes', js: true do
expect(page).to have_content("regular link") expect(page).to have_content("regular link")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/regular\">regular link</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/regular\">regular link</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/relative\">relative link 1</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/relative\">relative link 1</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/relative\">relative link 2</a>")
expect(page.html).to include("<a href=\"/#{project.path_with_namespace}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>") expect(page.html).to include("<a href=\"/#{project.full_path}/wikis/a-page/b-page/c-page/e/f/relative\">relative link 3</a>")
end end
end end
end end
......
...@@ -20,7 +20,7 @@ describe 'Projects > Wiki > User views Git access wiki page' do ...@@ -20,7 +20,7 @@ describe 'Projects > Wiki > User views Git access wiki page' do
visit project_wiki_path(project, wiki_page) visit project_wiki_path(project, wiki_page)
click_link 'Clone repository' click_link 'Clone repository'
expect(page).to have_text("Clone repository #{project.wiki.path_with_namespace}") expect(page).to have_text("Clone repository #{project.wiki.full_path}")
expect(page).to have_text(project.wiki.http_url_to_repo) expect(page).to have_text(project.wiki.http_url_to_repo)
end end
end end
...@@ -7,7 +7,7 @@ describe LabelsHelper do ...@@ -7,7 +7,7 @@ describe LabelsHelper do
context 'without subject' do context 'without subject' do
it "uses the label's project" do it "uses the label's project" do
expect(link_to_label(label)).to match %r{<a href="/#{label.project.path_with_namespace}/issues\?label_name%5B%5D=#{label.name}">.*</a>} expect(link_to_label(label)).to match %r{<a href="/#{label.project.full_path}/issues\?label_name%5B%5D=#{label.name}">.*</a>}
end end
end end
...@@ -32,7 +32,7 @@ describe LabelsHelper do ...@@ -32,7 +32,7 @@ describe LabelsHelper do
['issue', :issue, 'merge_request', :merge_request].each do |type| ['issue', :issue, 'merge_request', :merge_request].each do |type|
context "set to #{type}" do context "set to #{type}" do
it 'links to correct page' do it 'links to correct page' do
expect(link_to_label(label, type: type)).to match %r{<a href="/#{label.project.path_with_namespace}/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}">.*</a>} expect(link_to_label(label, type: type)).to match %r{<a href="/#{label.project.full_path}/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}">.*</a>}
end end
end end
end end
......
...@@ -210,11 +210,11 @@ describe MarkupHelper do ...@@ -210,11 +210,11 @@ describe MarkupHelper do
describe '#cross_project_reference' do describe '#cross_project_reference' do
it 'shows the full MR reference' do it 'shows the full MR reference' do
expect(helper.cross_project_reference(project, merge_request)).to include(project.path_with_namespace) expect(helper.cross_project_reference(project, merge_request)).to include(project.full_path)
end end
it 'shows the full issue reference' do it 'shows the full issue reference' do
expect(helper.cross_project_reference(project, issue)).to include(project.path_with_namespace) expect(helper.cross_project_reference(project, issue)).to include(project.full_path)
end end
end end
end end
...@@ -34,8 +34,8 @@ describe MergeRequestsHelper do ...@@ -34,8 +34,8 @@ describe MergeRequestsHelper do
let(:fork_project) { create(:empty_project, forked_from_project: project) } let(:fork_project) { create(:empty_project, forked_from_project: project) }
let(:merge_request) { create(:merge_request, source_project: fork_project, target_project: project) } let(:merge_request) { create(:merge_request, source_project: fork_project, target_project: project) }
subject { format_mr_branch_names(merge_request) } subject { format_mr_branch_names(merge_request) }
let(:source_title) { "#{fork_project.path_with_namespace}:#{merge_request.source_branch}" } let(:source_title) { "#{fork_project.full_path}:#{merge_request.source_branch}" }
let(:target_title) { "#{project.path_with_namespace}:#{merge_request.target_branch}" } let(:target_title) { "#{project.full_path}:#{merge_request.target_branch}" }
it { is_expected.to eq([source_title, target_title]) } it { is_expected.to eq([source_title, target_title]) }
end end
......
...@@ -53,13 +53,13 @@ describe ProjectsHelper do ...@@ -53,13 +53,13 @@ describe ProjectsHelper do
end end
it "returns a valid cach key" do it "returns a valid cach key" do
expect(helper.send(:readme_cache_key)).to eq("#{project.path_with_namespace}-#{project.commit.id}-readme") expect(helper.send(:readme_cache_key)).to eq("#{project.full_path}-#{project.commit.id}-readme")
end end
it "returns a valid cache key if HEAD does not exist" do it "returns a valid cache key if HEAD does not exist" do
allow(project).to receive(:commit) { nil } allow(project).to receive(:commit) { nil }
expect(helper.send(:readme_cache_key)).to eq("#{project.path_with_namespace}-nil-readme") expect(helper.send(:readme_cache_key)).to eq("#{project.full_path}-nil-readme")
end end
end end
......
...@@ -5,7 +5,7 @@ describe Banzai::Filter::AbstractReferenceFilter do ...@@ -5,7 +5,7 @@ describe Banzai::Filter::AbstractReferenceFilter do
describe '#references_per_project' do describe '#references_per_project' do
it 'returns a Hash containing references grouped per project paths' do it 'returns a Hash containing references grouped per project paths' do
doc = Nokogiri::HTML.fragment("#1 #{project.path_with_namespace}#2") doc = Nokogiri::HTML.fragment("#1 #{project.full_path}#2")
filter = described_class.new(doc, project: project) filter = described_class.new(doc, project: project)
expect(filter).to receive(:object_class).exactly(4).times.and_return(Issue) expect(filter).to receive(:object_class).exactly(4).times.and_return(Issue)
...@@ -14,7 +14,7 @@ describe Banzai::Filter::AbstractReferenceFilter do ...@@ -14,7 +14,7 @@ describe Banzai::Filter::AbstractReferenceFilter do
refs = filter.references_per_project refs = filter.references_per_project
expect(refs).to be_an_instance_of(Hash) expect(refs).to be_an_instance_of(Hash)
expect(refs[project.path_with_namespace]).to eq(Set.new(%w[1 2])) expect(refs[project.full_path]).to eq(Set.new(%w[1 2]))
end end
end end
...@@ -24,10 +24,10 @@ describe Banzai::Filter::AbstractReferenceFilter do ...@@ -24,10 +24,10 @@ describe Banzai::Filter::AbstractReferenceFilter do
filter = described_class.new(doc, project: project) filter = described_class.new(doc, project: project)
expect(filter).to receive(:references_per_project) expect(filter).to receive(:references_per_project)
.and_return({ project.path_with_namespace => Set.new(%w[1]) }) .and_return({ project.full_path => Set.new(%w[1]) })
expect(filter.projects_per_reference) expect(filter.projects_per_reference)
.to eq({ project.path_with_namespace => project }) .to eq({ project.full_path => project })
end end
end end
...@@ -37,7 +37,7 @@ describe Banzai::Filter::AbstractReferenceFilter do ...@@ -37,7 +37,7 @@ describe Banzai::Filter::AbstractReferenceFilter do
context 'with RequestStore disabled' do context 'with RequestStore disabled' do
it 'returns a list of Projects for a list of paths' do it 'returns a list of Projects for a list of paths' do
expect(filter.find_projects_for_paths([project.path_with_namespace])) expect(filter.find_projects_for_paths([project.full_path]))
.to eq([project]) .to eq([project])
end end
...@@ -49,7 +49,7 @@ describe Banzai::Filter::AbstractReferenceFilter do ...@@ -49,7 +49,7 @@ describe Banzai::Filter::AbstractReferenceFilter do
context 'with RequestStore enabled', :request_store do context 'with RequestStore enabled', :request_store do
it 'returns a list of Projects for a list of paths' do it 'returns a list of Projects for a list of paths' do
expect(filter.find_projects_for_paths([project.path_with_namespace])) expect(filter.find_projects_for_paths([project.full_path]))
.to eq([project]) .to eq([project])
end end
...@@ -88,7 +88,7 @@ describe Banzai::Filter::AbstractReferenceFilter do ...@@ -88,7 +88,7 @@ describe Banzai::Filter::AbstractReferenceFilter do
doc = Nokogiri::HTML.fragment('') doc = Nokogiri::HTML.fragment('')
filter = described_class.new(doc, project: project) filter = described_class.new(doc, project: project)
expect(filter.current_project_path).to eq(project.path_with_namespace) expect(filter.current_project_path).to eq(project.full_path)
end end
end end
end end
...@@ -100,7 +100,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter do ...@@ -100,7 +100,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
context 'cross-project / cross-namespace complete reference' do context 'cross-project / cross-namespace complete reference' do
let(:project2) { create(:project, :public, :repository) } let(:project2) { create(:project, :public, :repository) }
let(:reference) { "#{project2.path_with_namespace}@#{commit1.id}...#{commit2.id}" } let(:reference) { "#{project2.full_path}@#{commit1.id}...#{commit2.id}" }
it 'links to a valid reference' do it 'links to a valid reference' do
doc = reference_filter("See #{reference}") doc = reference_filter("See #{reference}")
...@@ -113,20 +113,20 @@ describe Banzai::Filter::CommitRangeReferenceFilter do ...@@ -113,20 +113,20 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
doc = reference_filter("Fixed (#{reference}.)") doc = reference_filter("Fixed (#{reference}.)")
expect(doc.css('a').first.text) expect(doc.css('a').first.text)
.to eql("#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}") .to eql("#{project2.full_path}@#{commit1.short_id}...#{commit2.short_id}")
end end
it 'has valid text' do it 'has valid text' do
doc = reference_filter("Fixed (#{reference}.)") doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eql("Fixed (#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}.)") expect(doc.text).to eql("Fixed (#{project2.full_path}@#{commit1.short_id}...#{commit2.short_id}.)")
end end
it 'ignores invalid commit IDs on the referenced project' do it 'ignores invalid commit IDs on the referenced project' do
exp = act = "Fixed #{project2.path_with_namespace}@#{commit1.id.reverse}...#{commit2.id}" exp = act = "Fixed #{project2.full_path}@#{commit1.id.reverse}...#{commit2.id}"
expect(reference_filter(act).to_html).to eq exp expect(reference_filter(act).to_html).to eq exp
exp = act = "Fixed #{project2.path_with_namespace}@#{commit1.id}...#{commit2.id.reverse}" exp = act = "Fixed #{project2.full_path}@#{commit1.id}...#{commit2.id.reverse}"
expect(reference_filter(act).to_html).to eq exp expect(reference_filter(act).to_html).to eq exp
end end
end end
......
...@@ -98,18 +98,18 @@ describe Banzai::Filter::CommitReferenceFilter do ...@@ -98,18 +98,18 @@ describe Banzai::Filter::CommitReferenceFilter do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit } let(:commit) { project2.commit }
let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" } let(:reference) { "#{project2.full_path}@#{commit.short_id}" }
it 'link has valid text' do it 'link has valid text' do
doc = reference_filter("See (#{reference}.)") doc = reference_filter("See (#{reference}.)")
expect(doc.css('a').first.text).to eql("#{project2.path_with_namespace}@#{commit.short_id}") expect(doc.css('a').first.text).to eql("#{project2.full_path}@#{commit.short_id}")
end end
it 'has valid text' do it 'has valid text' do
doc = reference_filter("See (#{reference}.)") doc = reference_filter("See (#{reference}.)")
expect(doc.text).to eql("See (#{project2.path_with_namespace}@#{commit.short_id}.)") expect(doc.text).to eql("See (#{project2.full_path}@#{commit.short_id}.)")
end end
it 'ignores invalid commit IDs on the referenced project' do it 'ignores invalid commit IDs on the referenced project' do
...@@ -124,7 +124,7 @@ describe Banzai::Filter::CommitReferenceFilter do ...@@ -124,7 +124,7 @@ describe Banzai::Filter::CommitReferenceFilter do
let(:project) { create(:empty_project, namespace: namespace) } let(:project) { create(:empty_project, namespace: namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit } let(:commit) { project2.commit }
let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" } let(:reference) { "#{project2.full_path}@#{commit.short_id}" }
it 'link has valid text' do it 'link has valid text' do
doc = reference_filter("See (#{reference}.)") doc = reference_filter("See (#{reference}.)")
...@@ -150,7 +150,7 @@ describe Banzai::Filter::CommitReferenceFilter do ...@@ -150,7 +150,7 @@ describe Banzai::Filter::CommitReferenceFilter do
let(:project) { create(:empty_project, namespace: namespace) } let(:project) { create(:empty_project, namespace: namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit } let(:commit) { project2.commit }
let(:reference) { "#{project2.path_with_namespace}@#{commit.short_id}" } let(:reference) { "#{project2.full_path}@#{commit.short_id}" }
it 'link has valid text' do it 'link has valid text' do
doc = reference_filter("See (#{reference}.)") doc = reference_filter("See (#{reference}.)")
......
...@@ -127,7 +127,7 @@ describe Banzai::Filter::IssueReferenceFilter do ...@@ -127,7 +127,7 @@ describe Banzai::Filter::IssueReferenceFilter do
let(:project2) { create(:empty_project, :public) } let(:project2) { create(:empty_project, :public) }
let(:issue) { create(:issue, project: project2) } let(:issue) { create(:issue, project: project2) }
let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } let(:reference) { "#{project2.full_path}##{issue.iid}" }
it 'ignores valid references when cross-reference project uses external tracker' do it 'ignores valid references when cross-reference project uses external tracker' do
expect_any_instance_of(described_class).to receive(:find_object) expect_any_instance_of(described_class).to receive(:find_object)
...@@ -148,13 +148,13 @@ describe Banzai::Filter::IssueReferenceFilter do ...@@ -148,13 +148,13 @@ describe Banzai::Filter::IssueReferenceFilter do
it 'link has valid text' do it 'link has valid text' do
doc = reference_filter("Fixed (#{reference}.)") doc = reference_filter("Fixed (#{reference}.)")
expect(doc.css('a').first.text).to eql("#{project2.path_with_namespace}##{issue.iid}") expect(doc.css('a').first.text).to eql("#{project2.full_path}##{issue.iid}")
end end
it 'has valid text' do it 'has valid text' do
doc = reference_filter("Fixed (#{reference}.)") doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eq("Fixed (#{project2.path_with_namespace}##{issue.iid}.)") expect(doc.text).to eq("Fixed (#{project2.full_path}##{issue.iid}.)")
end end
it 'ignores invalid issue IDs on the referenced project' do it 'ignores invalid issue IDs on the referenced project' do
...@@ -171,7 +171,7 @@ describe Banzai::Filter::IssueReferenceFilter do ...@@ -171,7 +171,7 @@ describe Banzai::Filter::IssueReferenceFilter do
let(:project) { create(:empty_project, :public, namespace: namespace) } let(:project) { create(:empty_project, :public, namespace: namespace) }
let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:project2) { create(:empty_project, :public, namespace: namespace) }
let(:issue) { create(:issue, project: project2) } let(:issue) { create(:issue, project: project2) }
let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } let(:reference) { "#{project2.full_path}##{issue.iid}" }
it 'ignores valid references when cross-reference project uses external tracker' do it 'ignores valid references when cross-reference project uses external tracker' do
expect_any_instance_of(described_class).to receive(:find_object) expect_any_instance_of(described_class).to receive(:find_object)
...@@ -324,10 +324,10 @@ describe Banzai::Filter::IssueReferenceFilter do ...@@ -324,10 +324,10 @@ describe Banzai::Filter::IssueReferenceFilter do
filter = described_class.new(doc, project: project) filter = described_class.new(doc, project: project)
expect(filter).to receive(:projects_per_reference) expect(filter).to receive(:projects_per_reference)
.and_return({ project.path_with_namespace => project }) .and_return({ project.full_path => project })
expect(filter).to receive(:references_per_project) expect(filter).to receive(:references_per_project)
.and_return({ project.path_with_namespace => Set.new([issue.iid]) }) .and_return({ project.full_path => Set.new([issue.iid]) })
expect(filter.issues_per_project) expect(filter.issues_per_project)
.to eq({ project => { issue.iid => issue } }) .to eq({ project => { issue.iid => issue } })
......
...@@ -368,7 +368,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -368,7 +368,7 @@ describe Banzai::Filter::LabelReferenceFilter do
describe 'cross-project / cross-namespace complete reference' do describe 'cross-project / cross-namespace complete reference' do
let(:project2) { create(:empty_project) } let(:project2) { create(:empty_project) }
let(:label) { create(:label, project: project2, color: '#00ff00') } let(:label) { create(:label, project: project2, color: '#00ff00') }
let(:reference) { "#{project2.path_with_namespace}~#{label.name}" } let(:reference) { "#{project2.full_path}~#{label.name}" }
let!(:result) { reference_filter("See #{reference}") } let!(:result) { reference_filter("See #{reference}") }
it 'links to a valid reference' do it 'links to a valid reference' do
...@@ -400,7 +400,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -400,7 +400,7 @@ describe Banzai::Filter::LabelReferenceFilter do
let(:project) { create(:empty_project, namespace: namespace) } let(:project) { create(:empty_project, namespace: namespace) }
let(:project2) { create(:empty_project, namespace: namespace) } let(:project2) { create(:empty_project, namespace: namespace) }
let(:label) { create(:label, project: project2, color: '#00ff00') } let(:label) { create(:label, project: project2, color: '#00ff00') }
let(:reference) { "#{project2.path_with_namespace}~#{label.name}" } let(:reference) { "#{project2.full_path}~#{label.name}" }
let!(:result) { reference_filter("See #{reference}") } let!(:result) { reference_filter("See #{reference}") }
it 'links to a valid reference' do it 'links to a valid reference' do
...@@ -466,7 +466,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -466,7 +466,7 @@ describe Banzai::Filter::LabelReferenceFilter do
let(:another_group) { create(:group) } let(:another_group) { create(:group) }
let(:another_project) { create(:empty_project, :public, namespace: another_group) } let(:another_project) { create(:empty_project, :public, namespace: another_group) }
let(:group_label) { create(:group_label, group: another_group, color: '#00ff00') } let(:group_label) { create(:group_label, group: another_group, color: '#00ff00') }
let(:reference) { "#{another_project.path_with_namespace}~#{group_label.name}" } let(:reference) { "#{another_project.full_path}~#{group_label.name}" }
let!(:result) { reference_filter("See #{reference}", project: project) } let!(:result) { reference_filter("See #{reference}", project: project) }
it 'points to referenced project issues page' do it 'points to referenced project issues page' do
...@@ -501,7 +501,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -501,7 +501,7 @@ describe Banzai::Filter::LabelReferenceFilter do
let(:project) { create(:empty_project, :public, namespace: group) } let(:project) { create(:empty_project, :public, namespace: group) }
let(:another_project) { create(:empty_project, :public, namespace: group) } let(:another_project) { create(:empty_project, :public, namespace: group) }
let(:group_label) { create(:group_label, group: group, color: '#00ff00') } let(:group_label) { create(:group_label, group: group, color: '#00ff00') }
let(:reference) { "#{another_project.path_with_namespace}~#{group_label.name}" } let(:reference) { "#{another_project.full_path}~#{group_label.name}" }
let!(:result) { reference_filter("See #{reference}", project: project) } let!(:result) { reference_filter("See #{reference}", project: project) }
it 'points to referenced project issues page' do it 'points to referenced project issues page' do
...@@ -535,7 +535,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -535,7 +535,7 @@ describe Banzai::Filter::LabelReferenceFilter do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:empty_project, :public, namespace: group) } let(:project) { create(:empty_project, :public, namespace: group) }
let(:group_label) { create(:group_label, group: group, color: '#00ff00') } let(:group_label) { create(:group_label, group: group, color: '#00ff00') }
let(:reference) { "#{project.path_with_namespace}~#{group_label.name}" } let(:reference) { "#{project.full_path}~#{group_label.name}" }
let!(:result) { reference_filter("See #{reference}", project: project) } let!(:result) { reference_filter("See #{reference}", project: project) }
it 'points to referenced project issues page' do it 'points to referenced project issues page' do
......
...@@ -102,7 +102,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter do ...@@ -102,7 +102,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
context 'cross-project / cross-namespace complete reference' do context 'cross-project / cross-namespace complete reference' do
let(:project2) { create(:empty_project, :public) } let(:project2) { create(:empty_project, :public) }
let(:merge) { create(:merge_request, source_project: project2) } let(:merge) { create(:merge_request, source_project: project2) }
let(:reference) { "#{project2.path_with_namespace}!#{merge.iid}" } let(:reference) { "#{project2.full_path}!#{merge.iid}" }
it 'links to a valid reference' do it 'links to a valid reference' do
doc = reference_filter("See #{reference}") doc = reference_filter("See #{reference}")
...@@ -135,7 +135,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter do ...@@ -135,7 +135,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
let(:project) { create(:empty_project, :public, namespace: namespace) } let(:project) { create(:empty_project, :public, namespace: namespace) }
let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:project2) { create(:empty_project, :public, namespace: namespace) }
let!(:merge) { create(:merge_request, source_project: project2) } let!(:merge) { create(:merge_request, source_project: project2) }
let(:reference) { "#{project2.path_with_namespace}!#{merge.iid}" } let(:reference) { "#{project2.full_path}!#{merge.iid}" }
it 'links to a valid reference' do it 'links to a valid reference' do
doc = reference_filter("See #{reference}") doc = reference_filter("See #{reference}")
......
...@@ -152,7 +152,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -152,7 +152,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:another_project) { create(:empty_project, :public, namespace: namespace) } let(:another_project) { create(:empty_project, :public, namespace: namespace) }
let(:milestone) { create(:milestone, project: another_project) } let(:milestone) { create(:milestone, project: another_project) }
let(:reference) { "#{another_project.path_with_namespace}%#{milestone.iid}" } let(:reference) { "#{another_project.full_path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") } let!(:result) { reference_filter("See #{reference}") }
it 'points to referenced project milestone page' do it 'points to referenced project milestone page' do
...@@ -164,14 +164,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -164,14 +164,14 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc = reference_filter("See (#{reference}.)") doc = reference_filter("See (#{reference}.)")
expect(doc.css('a').first.text) expect(doc.css('a').first.text)
.to eq("#{milestone.name} in #{another_project.path_with_namespace}") .to eq("#{milestone.name} in #{another_project.full_path}")
end end
it 'has valid text' do it 'has valid text' do
doc = reference_filter("See (#{reference}.)") doc = reference_filter("See (#{reference}.)")
expect(doc.text) expect(doc.text)
.to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") .to eq("See (#{milestone.name} in #{another_project.full_path}.)")
end end
it 'escapes the name attribute' do it 'escapes the name attribute' do
...@@ -180,7 +180,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -180,7 +180,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc = reference_filter("See #{reference}") doc = reference_filter("See #{reference}")
expect(doc.css('a').first.text) expect(doc.css('a').first.text)
.to eq "#{milestone.name} in #{another_project.path_with_namespace}" .to eq "#{milestone.name} in #{another_project.full_path}"
end end
end end
...@@ -189,7 +189,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -189,7 +189,7 @@ describe Banzai::Filter::MilestoneReferenceFilter do
let(:project) { create(:empty_project, :public, namespace: namespace) } let(:project) { create(:empty_project, :public, namespace: namespace) }
let(:another_project) { create(:empty_project, :public, namespace: namespace) } let(:another_project) { create(:empty_project, :public, namespace: namespace) }
let(:milestone) { create(:milestone, project: another_project) } let(:milestone) { create(:milestone, project: another_project) }
let(:reference) { "#{another_project.path_with_namespace}%#{milestone.iid}" } let(:reference) { "#{another_project.full_path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") } let!(:result) { reference_filter("See #{reference}") }
it 'points to referenced project milestone page' do it 'points to referenced project milestone page' do
...@@ -257,4 +257,28 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -257,4 +257,28 @@ describe Banzai::Filter::MilestoneReferenceFilter do
.to eq "#{milestone.name} in #{another_project.path}" .to eq "#{milestone.name} in #{another_project.path}"
end end
end end
describe 'cross project milestone references' do
let(:another_project) { create(:empty_project, :public) }
let(:project_path) { another_project.full_path }
let(:milestone) { create(:milestone, project: another_project) }
let(:reference) { milestone.to_reference(project) }
let!(:result) { reference_filter("See #{reference}") }
it 'points to referenced project milestone page' do
expect(result.css('a').first.attr('href')).to eq urls
.project_milestone_url(another_project, milestone)
end
it 'contains cross project content' do
expect(result.css('a').first.text).to eq "#{milestone.name} in #{project_path}"
end
it 'escapes the name attribute' do
allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="})
doc = reference_filter("See #{reference}")
expect(doc.css('a').first.text).to eq "#{milestone.name} in #{project_path}"
end
end
end end
...@@ -26,7 +26,7 @@ describe Banzai::Filter::RelativeLinkFilter do ...@@ -26,7 +26,7 @@ describe Banzai::Filter::RelativeLinkFilter do
end end
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:project_path) { project.path_with_namespace } let(:project_path) { project.full_path }
let(:ref) { 'markdown' } let(:ref) { 'markdown' }
let(:commit) { project.commit(ref) } let(:commit) { project.commit(ref) }
let(:project_wiki) { nil } let(:project_wiki) { nil }
......
...@@ -83,7 +83,7 @@ describe Banzai::Filter::SnippetReferenceFilter do ...@@ -83,7 +83,7 @@ describe Banzai::Filter::SnippetReferenceFilter do
let(:namespace) { create(:namespace) } let(:namespace) { create(:namespace) }
let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:project2) { create(:empty_project, :public, namespace: namespace) }
let!(:snippet) { create(:project_snippet, project: project2) } let!(:snippet) { create(:project_snippet, project: project2) }
let(:reference) { "#{project2.path_with_namespace}$#{snippet.id}" } let(:reference) { "#{project2.full_path}$#{snippet.id}" }
it 'links to a valid reference' do it 'links to a valid reference' do
doc = reference_filter("See #{reference}") doc = reference_filter("See #{reference}")
...@@ -116,7 +116,7 @@ describe Banzai::Filter::SnippetReferenceFilter do ...@@ -116,7 +116,7 @@ describe Banzai::Filter::SnippetReferenceFilter do
let(:project) { create(:empty_project, :public, namespace: namespace) } let(:project) { create(:empty_project, :public, namespace: namespace) }
let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:project2) { create(:empty_project, :public, namespace: namespace) }
let!(:snippet) { create(:project_snippet, project: project2) } let!(:snippet) { create(:project_snippet, project: project2) }
let(:reference) { "#{project2.path_with_namespace}$#{snippet.id}" } let(:reference) { "#{project2.full_path}$#{snippet.id}" }
it 'links to a valid reference' do it 'links to a valid reference' do
doc = reference_filter("See #{reference}") doc = reference_filter("See #{reference}")
......
...@@ -52,21 +52,21 @@ describe Banzai::Filter::UploadLinkFilter do ...@@ -52,21 +52,21 @@ describe Banzai::Filter::UploadLinkFilter do
it 'rebuilds relative URL for a link' do it 'rebuilds relative URL for a link' do
doc = filter(link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) doc = filter(link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" .to eq "#{Gitlab.config.gitlab.url}/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"
doc = filter(nested_link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) doc = filter(nested_link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))
expect(doc.at_css('a')['href']) expect(doc.at_css('a')['href'])
.to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" .to eq "#{Gitlab.config.gitlab.url}/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"
end end
it 'rebuilds relative URL for an image' do it 'rebuilds relative URL for an image' do
doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))
expect(doc.at_css('img')['src']) expect(doc.at_css('img')['src'])
.to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" .to eq "#{Gitlab.config.gitlab.url}/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"
doc = filter(nested_image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) doc = filter(nested_image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))
expect(doc.at_css('img')['src']) expect(doc.at_css('img')['src'])
.to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" .to eq "#{Gitlab.config.gitlab.url}/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"
end end
it 'does not modify absolute URL' do it 'does not modify absolute URL' do
...@@ -85,7 +85,7 @@ describe Banzai::Filter::UploadLinkFilter do ...@@ -85,7 +85,7 @@ describe Banzai::Filter::UploadLinkFilter do
.to receive(:image?).with(path).and_return(true) .to receive(:image?).with(path).and_return(true)
doc = filter(image(escaped)) doc = filter(image(escaped))
expect(doc.at_css('img')['src']).to match "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/%ED%95%9C%EA%B8%80.png" expect(doc.at_css('img')['src']).to match "#{Gitlab.config.gitlab.url}/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png"
end end
end end
......
...@@ -14,7 +14,7 @@ describe ExtractsPath do ...@@ -14,7 +14,7 @@ describe ExtractsPath do
repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0', repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0',
'release/app', 'release/app/v1.0.0']) 'release/app', 'release/app/v1.0.0'])
allow(project).to receive(:repository).and_return(repo) allow(project).to receive(:repository).and_return(repo)
allow(project).to receive(:path_with_namespace) allow(project).to receive(:full_path)
.and_return('gitlab/gitlab-ci') .and_return('gitlab/gitlab-ci')
allow(request).to receive(:format=) allow(request).to receive(:format=)
end end
...@@ -29,7 +29,7 @@ describe ExtractsPath do ...@@ -29,7 +29,7 @@ describe ExtractsPath do
it "log tree path has no escape sequences" do it "log tree path has no escape sequences" do
assign_ref_vars assign_ref_vars
expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb") expect(@logs_path).to eq("/#{@project.full_path}/refs/#{ref}/logs_tree/files/ruby/popen.rb")
end end
context 'ref contains %20' do context 'ref contains %20' do
......
...@@ -117,7 +117,7 @@ describe Gitlab::Email::Message::RepositoryPush do ...@@ -117,7 +117,7 @@ describe Gitlab::Email::Message::RepositoryPush do
describe '#subject' do describe '#subject' do
subject { message.subject } subject { message.subject }
it { is_expected.to include "[Git][#{project.path_with_namespace}]" } it { is_expected.to include "[Git][#{project.full_path}]" }
it { is_expected.to include "#{compare.commits.length} commits" } it { is_expected.to include "#{compare.commits.length} commits" }
it { is_expected.to include compare.commits.first.message.split("\n").first } it { is_expected.to include compare.commits.first.message.split("\n").first }
end end
......
...@@ -39,8 +39,8 @@ describe Gitlab::Gfm::UploadsRewriter do ...@@ -39,8 +39,8 @@ describe Gitlab::Gfm::UploadsRewriter do
it 'copies files' do it 'copies files' do
expect(new_files).to all(exist) expect(new_files).to all(exist)
expect(old_paths).not_to match_array new_paths expect(old_paths).not_to match_array new_paths
expect(old_paths).to all(include(old_project.path_with_namespace)) expect(old_paths).to all(include(old_project.full_path))
expect(new_paths).to all(include(new_project.path_with_namespace)) expect(new_paths).to all(include(new_project.full_path))
end end
it 'does not remove old files' do it 'does not remove old files' do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::GitalyClient::CommitService do describe Gitlab::GitalyClient::CommitService do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:storage_name) { project.repository_storage } let(:storage_name) { project.repository_storage }
let(:relative_path) { project.path_with_namespace + '.git' } let(:relative_path) { project.disk_path + '.git' }
let(:repository) { project.repository } let(:repository) { project.repository }
let(:repository_message) { repository.gitaly_repository } let(:repository_message) { repository.gitaly_repository }
let(:revision) { '913c66a37b4a45b9769037c55c2d238bd0942d2e' } let(:revision) { '913c66a37b4a45b9769037c55c2d238bd0942d2e' }
......
...@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::NotificationService do ...@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::NotificationService do
describe '#post_receive' do describe '#post_receive' do
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:storage_name) { project.repository_storage } let(:storage_name) { project.repository_storage }
let(:relative_path) { project.path_with_namespace + '.git' } let(:relative_path) { project.disk_path + '.git' }
subject { described_class.new(project.repository) } subject { described_class.new(project.repository) }
it 'sends a post_receive message' do it 'sends a post_receive message' do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::GitalyClient::RefService do describe Gitlab::GitalyClient::RefService do
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:storage_name) { project.repository_storage } let(:storage_name) { project.repository_storage }
let(:relative_path) { project.path_with_namespace + '.git' } let(:relative_path) { project.disk_path + '.git' }
let(:client) { described_class.new(project.repository) } let(:client) { described_class.new(project.repository) }
describe '#branches' do describe '#branches' do
......
...@@ -9,9 +9,9 @@ describe Gitlab::GithubImport::WikiFormatter do ...@@ -9,9 +9,9 @@ describe Gitlab::GithubImport::WikiFormatter do
subject(:wiki) { described_class.new(project) } subject(:wiki) { described_class.new(project) }
describe '#path_with_namespace' do describe '#disk_path' do
it 'appends .wiki to project path' do it 'appends .wiki to project path' do
expect(wiki.path_with_namespace).to eq 'gitlabhq/gitlabhq.wiki' expect(wiki.disk_path).to eq project.disk_path + '.wiki'
end end
end end
......
...@@ -5,7 +5,7 @@ describe 'forked project import' do ...@@ -5,7 +5,7 @@ describe 'forked project import' do
let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') } let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let!(:project) { create(:empty_project, name: 'test-repo-restorer-no-repo', path: 'test-repo-restorer-no-repo') } let!(:project) { create(:empty_project, name: 'test-repo-restorer-no-repo', path: 'test-repo-restorer-no-repo') }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.full_path) }
let(:forked_from_project) { create(:project) } let(:forked_from_project) { create(:project) }
let(:fork_link) { create(:forked_project_link, forked_from_project: project_with_repo) } let(:fork_link) { create(:forked_project_link, forked_from_project: project_with_repo) }
let(:repo_saver) { Gitlab::ImportExport::RepoSaver.new(project: project_with_repo, shared: shared) } let(:repo_saver) { Gitlab::ImportExport::RepoSaver.new(project: project_with_repo, shared: shared) }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::ProjectTreeSaver do describe Gitlab::ImportExport::ProjectTreeSaver do
describe 'saves the project tree into a json object' do describe 'saves the project tree into a json object' do
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.full_path) }
let(:project_tree_saver) { described_class.new(project: project, current_user: user, shared: shared) } let(:project_tree_saver) { described_class.new(project: project, current_user: user, shared: shared) }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -6,7 +6,7 @@ describe Gitlab::ImportExport::RepoRestorer do ...@@ -6,7 +6,7 @@ describe Gitlab::ImportExport::RepoRestorer do
let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') } let!(:project_with_repo) { create(:project, name: 'test-repo-restorer', path: 'test-repo-restorer') }
let!(:project) { create(:empty_project) } let!(:project) { create(:empty_project) }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.full_path) }
let(:bundler) { Gitlab::ImportExport::RepoSaver.new(project: project_with_repo, shared: shared) } let(:bundler) { Gitlab::ImportExport::RepoSaver.new(project: project_with_repo, shared: shared) }
let(:bundle_path) { File.join(shared.export_path, Gitlab::ImportExport.project_bundle_filename) } let(:bundle_path) { File.join(shared.export_path, Gitlab::ImportExport.project_bundle_filename) }
let(:restorer) do let(:restorer) do
......
...@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::RepoSaver do ...@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::RepoSaver do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:empty_project, :public, name: 'searchable_project') } let!(:project) { create(:empty_project, :public, name: 'searchable_project') }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.full_path) }
let(:bundler) { described_class.new(project: project, shared: shared) } let(:bundler) { described_class.new(project: project, shared: shared) }
before do before do
......
...@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::WikiRepoSaver do ...@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::WikiRepoSaver do
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:empty_project, :public, name: 'searchable_project') } let!(:project) { create(:empty_project, :public, name: 'searchable_project') }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.path_with_namespace) } let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: project.full_path) }
let(:wiki_bundler) { described_class.new(project: project, shared: shared) } let(:wiki_bundler) { described_class.new(project: project, shared: shared) }
let!(:project_wiki) { ProjectWiki.new(project, user) } let!(:project_wiki) { ProjectWiki.new(project, user) }
......
...@@ -8,7 +8,7 @@ describe Gitlab::UrlBuilder do ...@@ -8,7 +8,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(commit) url = described_class.build(commit)
expect(url).to eq "#{Settings.gitlab['url']}/#{commit.project.path_with_namespace}/commit/#{commit.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{commit.project.full_path}/commit/#{commit.id}"
end end
end end
...@@ -18,7 +18,7 @@ describe Gitlab::UrlBuilder do ...@@ -18,7 +18,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(issue) url = described_class.build(issue)
expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.path_with_namespace}/issues/#{issue.iid}" expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/issues/#{issue.iid}"
end end
end end
...@@ -28,7 +28,7 @@ describe Gitlab::UrlBuilder do ...@@ -28,7 +28,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(merge_request) url = described_class.build(merge_request)
expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.path_with_namespace}/merge_requests/#{merge_request.iid}" expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}"
end end
end end
...@@ -39,7 +39,7 @@ describe Gitlab::UrlBuilder do ...@@ -39,7 +39,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(note) url = described_class.build(note)
expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.path_with_namespace}/commit/#{note.commit_id}#note_#{note.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}"
end end
end end
...@@ -49,7 +49,7 @@ describe Gitlab::UrlBuilder do ...@@ -49,7 +49,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(note) url = described_class.build(note)
expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.path_with_namespace}/commit/#{note.commit_id}#note_#{note.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}"
end end
end end
...@@ -60,7 +60,7 @@ describe Gitlab::UrlBuilder do ...@@ -60,7 +60,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(note) url = described_class.build(note)
expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.path_with_namespace}/issues/#{issue.iid}#note_#{note.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/issues/#{issue.iid}#note_#{note.id}"
end end
end end
...@@ -71,7 +71,7 @@ describe Gitlab::UrlBuilder do ...@@ -71,7 +71,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(note) url = described_class.build(note)
expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.path_with_namespace}/merge_requests/#{merge_request.iid}#note_#{note.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}#note_#{note.id}"
end end
end end
...@@ -82,7 +82,7 @@ describe Gitlab::UrlBuilder do ...@@ -82,7 +82,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(note) url = described_class.build(note)
expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.path_with_namespace}/merge_requests/#{merge_request.iid}#note_#{note.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}#note_#{note.id}"
end end
end end
...@@ -93,7 +93,7 @@ describe Gitlab::UrlBuilder do ...@@ -93,7 +93,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(note) url = described_class.build(note)
expect(url).to eq "#{Settings.gitlab['url']}/#{project_snippet.project.path_with_namespace}/snippets/#{note.noteable_id}#note_#{note.id}" expect(url).to eq "#{Settings.gitlab['url']}/#{project_snippet.project.full_path}/snippets/#{note.noteable_id}#note_#{note.id}"
end end
end end
......
...@@ -4,7 +4,7 @@ require Rails.root.join('db', 'post_migrate', '20170502101023_cleanup_namespacel ...@@ -4,7 +4,7 @@ require Rails.root.join('db', 'post_migrate', '20170502101023_cleanup_namespacel
describe CleanupNamespacelessPendingDeleteProjects do describe CleanupNamespacelessPendingDeleteProjects do
before do before do
# Stub after_save callbacks that will fail when Project has no namespace # Stub after_save callbacks that will fail when Project has no namespace
allow_any_instance_of(Project).to receive(:ensure_dir_exist).and_return(nil) allow_any_instance_of(Project).to receive(:ensure_storage_path_exist).and_return(nil)
allow_any_instance_of(Project).to receive(:update_project_statistics).and_return(nil) allow_any_instance_of(Project).to receive(:update_project_statistics).and_return(nil)
end end
......
...@@ -20,7 +20,7 @@ describe MigrateProcessCommitWorkerJobs do ...@@ -20,7 +20,7 @@ describe MigrateProcessCommitWorkerJobs do
.find_including_path(project.id) .find_including_path(project.id)
expect(migration_project[:path_with_namespace]) expect(migration_project[:path_with_namespace])
.to eq(project.path_with_namespace) .to eq(project.full_path)
end end
end end
......
...@@ -44,7 +44,7 @@ describe TurnNestedGroupsIntoRegularGroupsForMysql do ...@@ -44,7 +44,7 @@ describe TurnNestedGroupsIntoRegularGroupsForMysql do
end end
it 'renames projects of the nested group' do it 'renames projects of the nested group' do
expect(updated_project.path_with_namespace) expect(updated_project.full_path)
.to eq("#{parent_group.name}-#{child_group.name}/#{updated_project.path}") .to eq("#{parent_group.name}-#{child_group.name}/#{updated_project.path}")
end end
......
...@@ -161,7 +161,7 @@ eos ...@@ -161,7 +161,7 @@ eos
end end
it 'detects issues that this commit is marked as closing' do it 'detects issues that this commit is marked as closing' do
ext_ref = "#{other_project.path_with_namespace}##{other_issue.iid}" ext_ref = "#{other_project.full_path}##{other_issue.iid}"
allow(commit).to receive_messages( allow(commit).to receive_messages(
safe_message: "Fixes ##{issue.iid} and #{ext_ref}", safe_message: "Fixes ##{issue.iid} and #{ext_ref}",
......
...@@ -250,7 +250,7 @@ describe MergeRequest do ...@@ -250,7 +250,7 @@ describe MergeRequest do
end end
it 'returns a String reference with the full path' do it 'returns a String reference with the full path' do
expect(merge_request.to_reference(full: true)).to eq(project.path_with_namespace + '!1') expect(merge_request.to_reference(full: true)).to eq(project.full_path + '!1')
end end
end end
......
...@@ -105,14 +105,14 @@ describe ProjectLabel do ...@@ -105,14 +105,14 @@ describe ProjectLabel do
context 'using name' do context 'using name' do
it 'returns cross reference with label name' do it 'returns cross reference with label name' do
expect(label.to_reference(project, format: :name)) expect(label.to_reference(project, format: :name))
.to eq %Q(#{label.project.path_with_namespace}~"#{label.name}") .to eq %Q(#{label.project.full_path}~"#{label.name}")
end end
end end
context 'using id' do context 'using id' do
it 'returns cross reference with label id' do it 'returns cross reference with label id' do
expect(label.to_reference(project, format: :id)) expect(label.to_reference(project, format: :id))
.to eq %Q(#{label.project.path_with_namespace}~#{label.id}) .to eq %Q(#{label.project.full_path}~#{label.id})
end end
end end
end end
......
...@@ -31,9 +31,9 @@ describe GitlabIssueTrackerService do ...@@ -31,9 +31,9 @@ describe GitlabIssueTrackerService do
end end
it 'gives the correct path' do it 'gives the correct path' do
expect(service.project_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.path_with_namespace}/issues") expect(service.project_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues")
expect(service.new_issue_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.path_with_namespace}/issues/new") expect(service.new_issue_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues/new")
expect(service.issue_url(432)).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.path_with_namespace}/issues/432") expect(service.issue_url(432)).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues/432")
end end
end end
...@@ -43,9 +43,9 @@ describe GitlabIssueTrackerService do ...@@ -43,9 +43,9 @@ describe GitlabIssueTrackerService do
end end
it 'gives the correct path' do it 'gives the correct path' do
expect(service.issue_tracker_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues") expect(service.issue_tracker_path).to eq("/gitlab/root/#{project.full_path}/issues")
expect(service.new_issue_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues/new") expect(service.new_issue_path).to eq("/gitlab/root/#{project.full_path}/issues/new")
expect(service.issue_path(432)).to eq("/gitlab/root/#{project.path_with_namespace}/issues/432") expect(service.issue_path(432)).to eq("/gitlab/root/#{project.full_path}/issues/432")
end end
end end
end end
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment