Skip to content
Snippets Groups Projects
Commit fb06a4d8 authored by Gabriel Mazetto's avatar Gabriel Mazetto
Browse files

Rename more path_with_namespace -> full_path or disk_path

parent c6dee998
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 40 deletions
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
Loading
Loading
@@ -480,7 +480,7 @@ class Project < ActiveRecord::Base
end
 
def repository
@repository ||= Repository.new(path_with_namespace, self)
@repository ||= Repository.new(full_path, disk_path, self)
end
 
def container_registry_url
Loading
Loading
@@ -945,7 +945,7 @@ class Project < ActiveRecord::Base
end
 
def url_to_repo
gitlab_shell.url_to_repo(path_with_namespace)
gitlab_shell.url_to_repo(full_path)
end
 
def repo_exists?
Loading
Loading
@@ -980,8 +980,9 @@ class Project < ActiveRecord::Base
 
# Expires various caches before a project is renamed.
def expire_caches_before_rename(old_path)
repo = Repository.new(old_path, self)
wiki = Repository.new("#{old_path}.wiki", self)
# TODO: if we start using UUIDs for cache, we don't need to do this HACK anymore
repo = Repository.new(old_path, old_path, self)
wiki = Repository.new("#{old_path}.wiki", "#{old_path}.wiki", self)
 
if repo.exists?
repo.before_delete
Loading
Loading
@@ -1209,6 +1210,7 @@ class Project < ActiveRecord::Base
deploy_keys.where(public: false).delete_all
end
 
# TODO: what to do here when not using Legacy Storage? Do we still need to rename and delay removal?
def remove_pages
::Projects::UpdatePagesConfigurationService.new(self).execute
 
Loading
Loading
class ProjectWiki
include Gitlab::ShellAdapter
include Storage::LegacyProjectWiki
 
MARKUPS = {
'Markdown' => :markdown,
Loading
Loading
@@ -26,16 +27,19 @@ class ProjectWiki
@project.path + '.wiki'
end
 
def path_with_namespace
def full_path
@project.full_path + '.wiki'
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
Gitlab::Routing.url_helpers.project_wiki_url(@project, :home)
end
 
def url_to_repo
gitlab_shell.url_to_repo(path_with_namespace)
gitlab_shell.url_to_repo(full_path)
end
 
def ssh_url_to_repo
Loading
Loading
@@ -43,11 +47,11 @@ class ProjectWiki
end
 
def http_url_to_repo
"#{Gitlab.config.gitlab.url}/#{path_with_namespace}.git"
"#{Gitlab.config.gitlab.url}/#{full_path}.git"
end
 
def wiki_base_path
[Gitlab.config.gitlab.relative_url_root, "/", @project.full_path, "/wikis"].join('')
[Gitlab.config.gitlab.relative_url_root, '/', @project.full_path, '/wikis'].join('')
end
 
# Returns the Gollum::Wiki object.
Loading
Loading
@@ -134,7 +138,7 @@ class ProjectWiki
end
 
def repository
@repository ||= Repository.new(path_with_namespace, @project)
@repository ||= Repository.new(full_path, disk_path, @project)
end
 
def default_branch
Loading
Loading
@@ -142,7 +146,7 @@ class ProjectWiki
end
 
def create_repo!
if init_repo(path_with_namespace)
if init_repo(disk_path)
wiki = Gollum::Wiki.new(path_to_repo)
else
raise CouldNotCreateWikiError
Loading
Loading
@@ -162,15 +166,15 @@ class ProjectWiki
web_url: web_url,
git_ssh_url: ssh_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
}
end
 
private
 
def init_repo(path_with_namespace)
gitlab_shell.add_repository(project.repository_storage_path, path_with_namespace)
def init_repo(disk_path)
gitlab_shell.add_repository(project.repository_storage_path, disk_path)
end
 
def commit_details(action, message = nil, title = nil)
Loading
Loading
@@ -184,7 +188,7 @@ class ProjectWiki
end
 
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
 
def update_project_activity
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ class Repository
include Gitlab::ShellAdapter
include RepositoryMirroring
 
attr_accessor :path_with_namespace, :project
attr_accessor :full_path, :disk_path, :project
 
delegate :ref_name_for_sha, to: :raw_repository
 
Loading
Loading
@@ -52,13 +52,14 @@ class Repository
end
end
 
def initialize(path_with_namespace, project)
@path_with_namespace = path_with_namespace
def initialize(full_path, disk_path, project)
@full_path = full_path
@disk_path = disk_path
@project = project
end
 
def raw_repository
return nil unless path_with_namespace
return nil unless full_path
 
@raw_repository ||= initialize_raw_repository
end
Loading
Loading
@@ -66,7 +67,7 @@ class Repository
# Return absolute path to repository
def path_to_repo
@path_to_repo ||= File.expand_path(
File.join(repository_storage_path, path_with_namespace + ".git")
File.join(repository_storage_path, disk_path + '.git')
)
end
 
Loading
Loading
@@ -469,7 +470,7 @@ class Repository
 
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/314
def exists?
return false unless path_with_namespace
return false unless full_path
 
Gitlab::GitalyClient.migrate(:repository_exists) do |enabled|
if enabled
Loading
Loading
@@ -1005,7 +1006,7 @@ class Repository
end
 
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
 
def fetch_ref(source_path, source_ref, target_ref)
Loading
Loading
@@ -1104,7 +1105,8 @@ class Repository
end
 
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
 
def tags_sorted_by_committed_date
Loading
Loading
@@ -1127,7 +1129,7 @@ class Repository
end
 
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
 
def create_commit(params = {})
Loading
Loading
@@ -1141,6 +1143,6 @@ class Repository
end
 
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
Loading
Loading
@@ -127,7 +127,7 @@ module Projects
def flush_caches(project)
project.repository.before_delete
 
Repository.new(wiki_path, project).before_delete
Repository.new(wiki_path, repo_path, project).before_delete
end
end
end
Loading
Loading
@@ -30,7 +30,7 @@ class FileUploader < GitlabUploader
#
# Returns a String without a trailing slash
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
 
attr_accessor :model
Loading
Loading
Loading
Loading
@@ -70,7 +70,7 @@
%span.badge
= storage_counter(project.statistics.storage_size)
%span.pull-right.light
%span.monospace= project.path_with_namespace + ".git"
%span.monospace= project.full_path + '.git'
.panel-footer
= paginate @projects, param_name: 'projects_page', theme: 'gitlab'
 
Loading
Loading
@@ -88,7 +88,7 @@
%span.badge
= storage_counter(project.statistics.storage_size)
%span.pull-right.light
%span.monospace= project.path_with_namespace + ".git"
%span.monospace= project.full_path + '.git'
 
.col-md-6
- if can?(current_user, :admin_group_member, @group)
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@
%td
= provider_project_link(provider, project.import_source)
%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
- if project.import_status == 'finished'
%span
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@
job.attr("id", "project_#{@project.id}")
target_field = job.find(".import-target")
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)
job.addClass("active").find(".import-actions").html("<i class='fa fa-spinner fa-spin'></i> started")
- else
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@
%td
= link_to project.import_source, "https://bitbucket.org/#{project.import_source}", target: '_blank', rel: 'noopener noreferrer'
%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
- if project.import_status == 'finished'
%span
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@
%td
= project.import_source
%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
- if project.import_status == 'finished'
%span
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@
%td
= link_to project.import_source, "https://gitlab.com/#{project.import_source}", target: "_blank"
%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
- if project.import_status == 'finished'
%span
Loading
Loading
Loading
Loading
@@ -38,7 +38,7 @@
%td
= link_to project.import_source, "https://code.google.com/p/#{project.import_source}", target: "_blank", rel: 'noopener noreferrer'
%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
- if project.import_status == 'finished'
%span
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@
- notes = commit.notes
- 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(cache_key, expires_in: 1.day) do
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@
Suggestions:
%code= 'gitlab'
%code= @project.path # Path contains no spaces, but dashes
%code= @project.path_with_namespace
%code= @project.full_path
%p
Reserved:
= link_to 'https://docs.mattermost.com/help/messaging/executing-commands.html#built-in-commands', target: '__blank' do
Loading
Loading
Loading
Loading
@@ -41,7 +41,7 @@
- projects = target_projects(@project)
.merge-request-select.dropdown
= 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_title("Select target project")
= dropdown_filter("Search projects")
Loading
Loading
Loading
Loading
@@ -2,4 +2,4 @@
- projects.each do |project|
%li
%a{ href: "#", class: "#{('is-active' if selected == project.id)}", data: { id: project.id } }
= project.path_with_namespace
= project.full_path
Loading
Loading
@@ -39,7 +39,7 @@
Suggestions:
%code= 'gitlab'
%code= @project.path # Path contains no spaces, but dashes
%code= @project.path_with_namespace
%code= @project.full_path
 
.form-group
= label_tag :request_url, 'Request URL', class: 'col-sm-2 col-xs-12 control-label'
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@
Suggestions:
%code= 'gitlab'
%code= @project.path # Path contains no spaces, but dashes
%code= @project.path_with_namespace
%code= @project.full_path
 
.form-group
= label_tag :url, 'URL', class: 'col-sm-2 col-xs-12 control-label'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment