Commit b0e2e760 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'sh-log-project-name-with-gitaly' into 'master'

Send project name with Gitaly repository requests

Closes gitaly#1394

See merge request gitlab-org/gitlab-ce!23373
parents 4551ca22 f929411c
...@@ -422,7 +422,7 @@ group :ed25519 do ...@@ -422,7 +422,7 @@ group :ed25519 do
end end
# Gitaly GRPC client # Gitaly GRPC client
gem 'gitaly-proto', '~> 1.5.0', require: 'gitaly' gem 'gitaly-proto', '~> 1.10.0', require: 'gitaly'
gem 'grpc', '~> 1.15.0' gem 'grpc', '~> 1.15.0'
gem 'google-protobuf', '~> 3.6' gem 'google-protobuf', '~> 3.6'
......
...@@ -278,7 +278,7 @@ GEM ...@@ -278,7 +278,7 @@ GEM
gettext_i18n_rails (>= 0.7.1) gettext_i18n_rails (>= 0.7.1)
po_to_json (>= 1.0.0) po_to_json (>= 1.0.0)
rails (>= 3.2.0) rails (>= 3.2.0)
gitaly-proto (1.5.0) gitaly-proto (1.10.0)
grpc (~> 1.0) grpc (~> 1.0)
github-markup (1.7.0) github-markup (1.7.0)
gitlab-default_value_for (3.1.1) gitlab-default_value_for (3.1.1)
...@@ -1020,7 +1020,7 @@ DEPENDENCIES ...@@ -1020,7 +1020,7 @@ DEPENDENCIES
gettext (~> 3.2.2) gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3) gettext_i18n_rails_js (~> 1.3)
gitaly-proto (~> 1.5.0) gitaly-proto (~> 1.10.0)
github-markup (~> 1.7.0) github-markup (~> 1.7.0)
gitlab-default_value_for (~> 3.1.1) gitlab-default_value_for (~> 3.1.1)
gitlab-markup (~> 1.6.5) gitlab-markup (~> 1.6.5)
......
...@@ -96,7 +96,9 @@ class PoolRepository < ActiveRecord::Base ...@@ -96,7 +96,9 @@ class PoolRepository < ActiveRecord::Base
@object_pool ||= Gitlab::Git::ObjectPool.new( @object_pool ||= Gitlab::Git::ObjectPool.new(
shard.name, shard.name,
disk_path + '.git', disk_path + '.git',
source_project.repository.raw) source_project.repository.raw,
source_project.full_path
)
end end
def inspect def inspect
......
...@@ -1288,7 +1288,7 @@ class Project < ActiveRecord::Base ...@@ -1288,7 +1288,7 @@ class Project < ActiveRecord::Base
# Forked import is handled asynchronously # Forked import is handled asynchronously
return if forked? && !force return if forked? && !force
if gitlab_shell.create_repository(repository_storage, disk_path) if gitlab_shell.create_project_repository(self)
repository.after_create repository.after_create
true true
else else
......
...@@ -60,7 +60,7 @@ class ProjectWiki ...@@ -60,7 +60,7 @@ class ProjectWiki
def wiki def wiki
@wiki ||= begin @wiki ||= begin
gl_repository = Gitlab::GlRepository.gl_repository(project, true) gl_repository = Gitlab::GlRepository.gl_repository(project, true)
raw_repository = Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', gl_repository) raw_repository = Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', gl_repository, full_path)
create_repo!(raw_repository) unless raw_repository.exists? create_repo!(raw_repository) unless raw_repository.exists?
...@@ -175,7 +175,7 @@ class ProjectWiki ...@@ -175,7 +175,7 @@ class ProjectWiki
private private
def create_repo!(raw_repository) def create_repo!(raw_repository)
gitlab_shell.create_repository(project.repository_storage, disk_path) gitlab_shell.create_wiki_repository(project)
raise CouldNotCreateWikiError unless raw_repository.exists? raise CouldNotCreateWikiError unless raw_repository.exists?
......
...@@ -1104,6 +1104,9 @@ class Repository ...@@ -1104,6 +1104,9 @@ class Repository
end end
def initialize_raw_repository def initialize_raw_repository
Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', Gitlab::GlRepository.gl_repository(project, is_wiki)) Gitlab::Git::Repository.new(project.repository_storage,
disk_path + '.git',
Gitlab::GlRepository.gl_repository(project, is_wiki),
project.full_path)
end end
end end
...@@ -73,7 +73,7 @@ module Projects ...@@ -73,7 +73,7 @@ module Projects
project.ensure_repository project.ensure_repository
project.repository.fetch_as_mirror(project.import_url, refmap: refmap) project.repository.fetch_as_mirror(project.import_url, refmap: refmap)
else else
gitlab_shell.import_repository(project.repository_storage, project.disk_path, project.import_url) gitlab_shell.import_project_repository(project)
end end
rescue Gitlab::Shell::Error => e rescue Gitlab::Shell::Error => e
# Expire cache to prevent scenarios such as: # Expire cache to prevent scenarios such as:
......
...@@ -15,19 +15,19 @@ class RepositoryForkWorker ...@@ -15,19 +15,19 @@ class RepositoryForkWorker
return target_project.import_state.mark_as_failed(_('Source project cannot be found.')) return target_project.import_state.mark_as_failed(_('Source project cannot be found.'))
end end
fork_repository(target_project, source_project.repository_storage, source_project.disk_path) fork_repository(target_project, source_project)
end end
private private
def fork_repository(target_project, source_repository_storage_name, source_disk_path) def fork_repository(target_project, source_project)
return unless start_fork(target_project) return unless start_fork(target_project)
Gitlab::Metrics.add_event(:fork_repository) Gitlab::Metrics.add_event(:fork_repository)
result = gitlab_shell.fork_repository(source_repository_storage_name, source_disk_path, result = gitlab_shell.fork_repository(source_project, target_project)
target_project.repository_storage, target_project.disk_path)
raise "Unable to fork project #{target_project.id} for repository #{source_disk_path} -> #{target_project.disk_path}" unless result raise "Unable to fork project #{target_project.id} for repository #{source_project.disk_path} -> #{target_project.disk_path}" unless result
target_project.after_import target_project.after_import
end end
......
...@@ -11,7 +11,7 @@ class MigrateRepoSize < ActiveRecord::Migration[4.2] ...@@ -11,7 +11,7 @@ class MigrateRepoSize < ActiveRecord::Migration[4.2]
path = File.join(namespace_path, project['project_path'] + '.git') path = File.join(namespace_path, project['project_path'] + '.git')
begin begin
repo = Gitlab::Git::Repository.new('default', path, '') repo = Gitlab::Git::Repository.new('default', path, '', '')
if repo.empty? if repo.empty?
print '-' print '-'
else else
......
...@@ -93,7 +93,7 @@ module Backup ...@@ -93,7 +93,7 @@ module Backup
progress.puts "Error: #{e}".color(:red) progress.puts "Error: #{e}".color(:red)
end end
else else
restore_repo_success = gitlab_shell.create_repository(project.repository_storage, project.disk_path) restore_repo_success = gitlab_shell.create_project_repository(project)
end end
if restore_repo_success if restore_repo_success
......
...@@ -65,9 +65,9 @@ module Gitlab ...@@ -65,9 +65,9 @@ module Gitlab
def import_wiki def import_wiki
return if project.wiki.repository_exists? return if project.wiki.repository_exists?
disk_path = project.wiki.disk_path wiki = WikiFormatter.new(project)
import_url = project.import_url.sub(/\.git\z/, ".git/wiki")
gitlab_shell.import_repository(project.repository_storage, disk_path, import_url) gitlab_shell.import_wiki_repository(project, wiki)
rescue StandardError => e rescue StandardError => e
errors << { type: :wiki, errors: e.message } errors << { type: :wiki, errors: e.message }
end end
......
# frozen_string_literal: true
module Gitlab
module BitbucketImport
class WikiFormatter
attr_reader :project
def initialize(project)
@project = project
end
def disk_path
project.wiki.disk_path
end
def full_path
project.wiki.full_path
end
def import_url
project.import_url.sub(/\.git\z/, ".git/wiki")
end
end
end
end
...@@ -10,12 +10,13 @@ module Gitlab ...@@ -10,12 +10,13 @@ module Gitlab
delegate :exists?, :size, to: :repository delegate :exists?, :size, to: :repository
delegate :unlink_repository, :delete, to: :object_pool_service delegate :unlink_repository, :delete, to: :object_pool_service
attr_reader :storage, :relative_path, :source_repository attr_reader :storage, :relative_path, :source_repository, :gl_project_path
def initialize(storage, relative_path, source_repository) def initialize(storage, relative_path, source_repository, gl_project_path)
@storage = storage @storage = storage
@relative_path = relative_path @relative_path = relative_path
@source_repository = source_repository @source_repository = source_repository
@gl_project_path = gl_project_path
end end
def create def create
...@@ -31,12 +32,12 @@ module Gitlab ...@@ -31,12 +32,12 @@ module Gitlab
end end
def to_gitaly_repository def to_gitaly_repository
Gitlab::GitalyClient::Util.repository(storage, relative_path, GL_REPOSITORY) Gitlab::GitalyClient::Util.repository(storage, relative_path, GL_REPOSITORY, gl_project_path)
end end
# Allows for reusing other RPCs by 'tricking' Gitaly to think its a repository # Allows for reusing other RPCs by 'tricking' Gitaly to think its a repository
def repository def repository
@repository ||= Gitlab::Git::Repository.new(storage, relative_path, GL_REPOSITORY) @repository ||= Gitlab::Git::Repository.new(storage, relative_path, GL_REPOSITORY, gl_project_path)
end end
private private
......
...@@ -67,7 +67,7 @@ module Gitlab ...@@ -67,7 +67,7 @@ module Gitlab
# Relative path of repo # Relative path of repo
attr_reader :relative_path attr_reader :relative_path
attr_reader :storage, :gl_repository, :relative_path attr_reader :storage, :gl_repository, :relative_path, :gl_project_path
# This remote name has to be stable for all types of repositories that # This remote name has to be stable for all types of repositories that
# can join an object pool. If it's structure ever changes, a migration # can join an object pool. If it's structure ever changes, a migration
...@@ -78,10 +78,11 @@ module Gitlab ...@@ -78,10 +78,11 @@ module Gitlab
# This initializer method is only used on the client side (gitlab-ce). # This initializer method is only used on the client side (gitlab-ce).
# Gitaly-ruby uses a different initializer. # Gitaly-ruby uses a different initializer.
def initialize(storage, relative_path, gl_repository) def initialize(storage, relative_path, gl_repository, gl_project_path)
@storage = storage @storage = storage
@relative_path = relative_path @relative_path = relative_path
@gl_repository = gl_repository @gl_repository = gl_repository
@gl_project_path = gl_project_path
@name = @relative_path.split("/").last @name = @relative_path.split("/").last
end end
...@@ -872,7 +873,7 @@ module Gitlab ...@@ -872,7 +873,7 @@ module Gitlab
end end
def gitaly_repository def gitaly_repository
Gitlab::GitalyClient::Util.repository(@storage, @relative_path, @gl_repository) Gitlab::GitalyClient::Util.repository(@storage, @relative_path, @gl_repository, @gl_project_path)
end end
def gitaly_ref_client def gitaly_ref_client
......
...@@ -4,7 +4,7 @@ module Gitlab ...@@ -4,7 +4,7 @@ module Gitlab
module GitalyClient module GitalyClient
module Util module Util
class << self class << self
def repository(repository_storage, relative_path, gl_repository) def repository(repository_storage, relative_path, gl_repository, gl_project_path)
git_env = Gitlab::Git::HookEnv.all(gl_repository) git_env = Gitlab::Git::HookEnv.all(gl_repository)
git_object_directory = git_env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence git_object_directory = git_env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence
git_alternate_object_directories = Array.wrap(git_env['GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE']) git_alternate_object_directories = Array.wrap(git_env['GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'])
...@@ -14,14 +14,16 @@ module Gitlab ...@@ -14,14 +14,16 @@ module Gitlab
relative_path: relative_path, relative_path: relative_path,
gl_repository: gl_repository.to_s, gl_repository: gl_repository.to_s,
git_object_directory: git_object_directory.to_s, git_object_directory: git_object_directory.to_s,
git_alternate_object_directories: git_alternate_object_directories git_alternate_object_directories: git_alternate_object_directories,
gl_project_path: gl_project_path
) )
end end
def git_repository(gitaly_repository) def git_repository(gitaly_repository)
Gitlab::Git::Repository.new(gitaly_repository.storage_name, Gitlab::Git::Repository.new(gitaly_repository.storage_name,
gitaly_repository.relative_path, gitaly_repository.relative_path,
gitaly_repository.gl_repository) gitaly_repository.gl_repository,
gitaly_repository.gl_project_path)
end end
end end
end end
......
...@@ -6,11 +6,12 @@ module Gitlab ...@@ -6,11 +6,12 @@ module Gitlab
class RepositoryImporter class RepositoryImporter
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
attr_reader :project, :client attr_reader :project, :client, :wiki_formatter
def initialize(project, client) def initialize(project, client)
@project = project @project = project
@client = client @client = client
@wiki_formatter = ::Gitlab::LegacyGithubImport::WikiFormatter.new(project)
end end
# Returns true if we should import the wiki for the project. # Returns true if we should import the wiki for the project.
...@@ -57,9 +58,7 @@ module Gitlab ...@@ -57,9 +58,7 @@ module Gitlab
end end
def import_wiki_repository def import_wiki_repository
wiki_path = "#{project.disk_path}.wiki" gitlab_shell.import_wiki_repository(project, wiki_formatter)
gitlab_shell.import_repository(project.repository_storage, wiki_path, wiki_url)
true true
rescue Gitlab::Shell::Error => e rescue Gitlab::Shell::Error => e
...@@ -72,7 +71,7 @@ module Gitlab ...@@ -72,7 +71,7 @@ module Gitlab
end end
def wiki_url def wiki_url
project.import_url.sub(/\.git\z/, '.wiki.git') wiki_formatter.import_url
end end
def update_clone_time def update_clone_time
......
...@@ -267,7 +267,7 @@ module Gitlab ...@@ -267,7 +267,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, wiki.disk_path, wiki.import_url) gitlab_shell.import_wiki_repository(project, wiki)
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,
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
project.wiki.disk_path project.wiki.disk_path
end end
def full_path
project.wiki.full_path
end
def import_url def import_url
project.import_url.sub(/\.git\z/, ".wiki.git") project.import_url.sub(/\.git\z/, ".wiki.git")
end end
......
...@@ -64,27 +64,48 @@ module Gitlab ...@@ -64,27 +64,48 @@ module Gitlab
end end
end end
# Convenience methods for initializing a new repository with a Project model.
def create_project_repository(project)
create_repository(project.repository_storage, project.disk_path, project.full_path)
end
def create_wiki_repository(project)
create_repository(project.repository_storage, project.wiki.disk_path, project.wiki.full_path)
end
# Init new repository # Init new repository
# #
# storage - the shard key # storage - the shard key
# name - project disk path # disk_path - project disk path
# gl_project_path - project name
# #
# Ex. # Ex.
# create_repository("default", "gitlab/gitlab-ci") # create_repository("default", "path/to/gitlab-ci", "gitlab/gitlab-ci")
# #
def create_repository(storage, name) def create_repository(storage, disk_path, gl_project_path)
relative_path = name.dup relative_path = disk_path.dup
relative_path << '.git' unless relative_path.end_with?('.git') relative_path << '.git' unless relative_path.end_with?('.git')
repository = Gitlab::Git::Repository.new(storage, relative_path, '') # During creation of a repository, gl_repository may not be known
# because that depends on a yet-to-be assigned project ID in the
# database (e.g. project-1234), so for now it is blank.
repository = Gitlab::Git::Repository.new(storage, relative_path, '', gl_project_path)
wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository } wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository }
true true
rescue => err # Once the Rugged codes gets removes this can be improved rescue => err # Once the Rugged codes gets removes this can be improved
Rails.logger.error("Failed to add repository #{storage}/#{name}: #{err}") Rails.logger.error("Failed to add repository #{storage}/#{disk_path}: #{err}")
false false
end end
def import_wiki_repository(project, wiki_formatter)
import_repository(project.repository_storage, wiki_formatter.disk_path, wiki_formatter.import_url, project.wiki.full_path)
end
def import_project_repository(project)
import_repository(project.repository_storage, project.disk_path, project.import_url, project.full_path)
end
# Import repository # Import repository
# #
# storage - project's storage name # storage - project's storage name
...@@ -94,13 +115,13 @@ module Gitlab ...@@ -94,13 +115,13 @@ module Gitlab
# Ex. # Ex.
# import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git") # import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git")
# #
def import_repository(storage, name, url) def import_repository(storage, name, url, gl_project_path)
if url.start_with?('.', '/') if url.start_with?('.', '/')
raise Error.new("don't use disk paths with import_repository: #{url.inspect}") raise Error.new("don't use disk paths with import_repository: #{url.inspect}")
end end
relative_path = "#{name}.git" relative_path = "#{name}.git"
cmd = GitalyGitlabProjects.new(storage, relative_path) cmd = GitalyGitlabProjects.new(storage, relative_path, gl_project_path)
success = cmd.import_project(url, git_timeout) success = cmd.import_project(url, git_timeout)
raise Error, cmd.output unless success raise Error, cmd.output unless success
...@@ -125,18 +146,13 @@ module Gitlab ...@@ -125,18 +146,13 @@ module Gitlab
end end
# Fork repository to new path # Fork repository to new path
# forked_from_storage - forked-from project's storage name # source_project - forked-from Project
# forked_from_disk_path - project disk relative path # target_project - forked-to Project
# forked_to_storage - forked-to project's storage name def fork_repository(source_project, target_project)
# forked_to_disk_path - forked project disk relative path forked_from_relative_path = "#{source_project.disk_path}.git"
# fork_args = [target_project.repository_storage, "#{target_project.disk_path}.git", target_project.full_path]
# Ex.
# fork_repository("nfs-file06", "gitlab/gitlab-ci", "nfs-file07", "new-namespace/gitlab-ci")
def fork_repository(forked_from_storage, forked_from_disk_path, forked_to_storage, forked_to_disk_path)
forked_from_relative_path = "#{forked_from_disk_path}.git"
fork_args = [forked_to_storage, "#{forked_to_disk_path}.git"]
GitalyGitlabProjects.new(forked_from_storage, forked_from_relative_path).fork_repository(*fork_args) GitalyGitlabProjects.new(source_project.repository_storage, forked_from_relative_path, source_project.full_path).fork_repository(*fork_args)
end end
# Removes a repository from file system, using rm_diretory which is an alias # Removes a repository from file system, using rm_diretory which is an alias
...@@ -397,16 +413,17 @@ module Gitlab ...@@ -397,16 +413,17 @@ module Gitlab
end end
class GitalyGitlabProjects class GitalyGitlabProjects
attr_reader :shard_name, :repository_relative_path, :output attr_reader :shard_name, :repository_relative_path, :output, :gl_project_path
def initialize(shard_name, repository_relative_path) def initialize(shard_name, repository_relative_path, gl_project_path)
@shard_name = shard_name @shard_name = shard_name
@repository_relative_path = repository_relative_path @repository_relative_path = repository_relative_path
@output = '' @output = ''
@gl_project_path = gl_project_path
end end
def import_project(source, _timeout) def import_project(source, _timeout)
raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil) raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil, gl_project_path)
Gitlab::GitalyClient::RepositoryService.new(raw_repository).import_repository(source) Gitlab::GitalyClient::RepositoryService.new(raw_repository).import_repository(source)
true true
...@@ -415,9 +432,9 @@ module Gitlab ...@@ -415,9 +432,9 @@ module Gitlab
false false
end end
def fork_repository(new_shard_name, new_repository_relative_path) def fork_repository(new_shard_name, new_repository_relative_path, new_project_name)
target_repository = Gitlab::Git::Repository.new(new_shard_name, new_repository_relative_path, nil) target_repository = Gitlab::Git::Repository.new(new_shard_name, new_repository_relative_path, nil, new_project_name)
raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil) raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil, gl_project_path)
Gitlab::GitalyClient::RepositoryService.new(target_repository).fork_repository(raw_repository) Gitlab::GitalyClient::RepositoryService.new(target_repository).fork_repository(raw_repository)
rescue GRPC::BadStatus => e rescue GRPC::BadStatus => e
......
...@@ -61,7 +61,7 @@ describe ::Gitlab::BareRepositoryImport::Repository do ...@@ -61,7 +61,7 @@ describe ::Gitlab::BareRepositoryImport::Repository do
let(:wiki_path) { File.join(root_path, "#{hashed_path}.wiki.git") } let(:wiki_path) { File.join(root_path, "#{hashed_path}.wiki.git") }
before do before do
gitlab_shell.create_repository(repository_storage, hashed_path) gitlab_shell.create_repository(repository_storage, hashed_path, 'group/project')
Gitlab::GitalyClient::StorageSettings.allow_disk_access do Gitlab::GitalyClient::StorageSettings.allow_disk_access do
repository = Rugged::Repository.new(repo_path) repository = Rugged::Repository.new(repo_path)
repository.config['gitlab.fullpath'] = 'to/repo' repository.config['gitlab.fullpath'] = 'to/repo'
......
...@@ -218,7 +218,7 @@ describe Gitlab::BitbucketImport::Importer do ...@@ -218,7 +218,7 @@ describe Gitlab::BitbucketImport::Importer do
describe 'wiki import' do describe 'wiki import' do
it 'is skipped when the wiki exists' do it 'is skipped when the wiki exists' do
expect(project.wiki).to receive(:repository_exists?) { true } expect(project.wiki).to receive(:repository_exists?) { true }
expect(importer.gitlab_shell).not_to receive(:import_repository) expect(importer.gitlab_shell).not_to receive(:import_wiki_repository)
importer.execute importer.execute
...@@ -227,11 +227,7 @@ describe Gitlab::BitbucketImport::Importer do ...@@ -227,11 +227,7 @@ describe Gitlab::BitbucketImport::Importer do
it 'imports to the project disk_path' do it 'imports to the project disk_path' do
expect(project.wiki).to receive(:repository_exists?) { false } expect(project.wiki).to receive(:repository_exists?) { false }
expect(importer.gitlab_shell).to receive(:import_repository).with( expect(importer.gitlab_shell).to receive(:import_wiki_repository)
project.repository_storage,
project.wiki.disk_path,
project.import_url + '/wiki'
)
importer.execute importer.execute
......
require 'spec_helper'
describe Gitlab::BitbucketImport::WikiFormatter do
let(:project) do
create(:project,
namespace: create(:namespace, path: 'gitlabhq'),
import_url: 'https://xxx@bitbucket.org/gitlabhq/sample.gitlabhq.git')
end
subject(:wiki) { described_class.new(project) }
describe '#disk_path' do
it 'appends .wiki to disk path' do
expect(wiki.disk_path).to eq project.wiki.disk_path
end
end
describe '#full_path' do
it 'appends .wiki to project path' do
expect(wiki.full_path).to eq project.wiki.full_path
end
end
describe '#import_url' do
it 'returns URL of the wiki repository' do
expect(wiki.import_url).to eq 'https://xxx@bitbucket.org/gitlabhq/sample.gitlabhq.git/wiki'
end
end
end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require "spec_helper" require "spec_helper"
describe Gitlab::Git::Blame, :seed_helper do describe Gitlab::Git::Blame, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:blame) do let(:blame) do
Gitlab::Git::Blame.new(repository, SeedRepo::Commit::ID, "CONTRIBUTING.md") Gitlab::Git::Blame.new(repository, SeedRepo::Commit::ID, "CONTRIBUTING.md")
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require "spec_helper" require "spec_helper"
describe Gitlab::Git::Blob, :seed_helper do describe Gitlab::Git::Blob, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:rugged) do let(:rugged) do
Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH)) Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH))
end end
......
require "spec_helper" require "spec_helper"
describe Gitlab::Git::Branch, :seed_helper do describe Gitlab::Git::Branch, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:rugged) do let(:rugged) do
Rugged::Repository.new(File.join(TestEnv.repos_path, repository.relative_path)) Rugged::Repository.new(File.join(TestEnv.repos_path, repository.relative_path))
end end
...@@ -64,7 +64,7 @@ describe Gitlab::Git::Branch, :seed_helper do ...@@ -64,7 +64,7 @@ describe Gitlab::Git::Branch, :seed_helper do
context 'with active, stale and future branches' do context 'with active, stale and future branches' do
let(:repository) do let(:repository) do
Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '', 'group/project')
end end
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -3,7 +3,7 @@ require "spec_helper" ...@@ -3,7 +3,7 @@ require "spec_helper"
describe Gitlab::Git::Commit, :seed_helper do describe Gitlab::Git::Commit, :seed_helper do
include GitHelpers include GitHelpers
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:rugged_repo) do let(:rugged_repo) do
Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH)) Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH))
end end
...@@ -146,7 +146,7 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -146,7 +146,7 @@ describe Gitlab::Git::Commit, :seed_helper do
end end
context 'with broken repo' do context 'with broken repo' do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_BROKEN_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_BROKEN_REPO_PATH, '', 'group/project') }
it 'returns nil' do it 'returns nil' do
expect(described_class.find(repository, SeedRepo::Commit::ID)).to be_nil expect(described_class.find(repository, SeedRepo::Commit::ID)).to be_nil
......
require "spec_helper" require "spec_helper"
describe Gitlab::Git::Compare, :seed_helper do describe Gitlab::Git::Compare, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: false) } let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: false) }
let(:compare_straight) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: true) } let(:compare_straight) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: true) }
......
require "spec_helper" require "spec_helper"
describe Gitlab::Git::Diff, :seed_helper do describe Gitlab::Git::Diff, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:gitaly_diff) do let(:gitaly_diff) do
Gitlab::GitalyClient::Diff.new( Gitlab::GitalyClient::Diff.new(
from_path: '.gitmodules', from_path: '.gitmodules',
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Git::RemoteRepository, :seed_helper do describe Gitlab::Git::RemoteRepository, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
subject { described_class.new(repository) } subject { described_class.new(repository) }
describe '#empty?' do describe '#empty?' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:repository, :result) do where(:repository, :result) do
Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') | false Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') | false
Gitlab::Git::Repository.new('default', 'does-not-exist.git', '') | true Gitlab::Git::Repository.new('default', 'does-not-exist.git', '', 'group/project') | true
end end
with_them do with_them do
...@@ -44,11 +44,11 @@ describe Gitlab::Git::RemoteRepository, :seed_helper do ...@@ -44,11 +44,11 @@ describe Gitlab::Git::RemoteRepository, :seed_helper do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:other_repository, :result) do where(:other_repository, :result) do
repository | true repository | true
Gitlab::Git::Repository.new(repository.storage, repository.relative_path, '') | true Gitlab::Git::Repository.new(repository.storage, repository.relative_path, '', 'group/project') | true
Gitlab::Git::Repository.new('broken', TEST_REPO_PATH, '') | false Gitlab::Git::Repository.new('broken', TEST_REPO_PATH, '', 'group/project') | false
Gitlab::Git::Repository.new(repository.storage, 'wrong/relative-path.git', '') | false Gitlab::Git::Repository.new(repository.storage, 'wrong/relative-path.git', '', 'group/project') | false
Gitlab::Git::Repository.new('broken', 'wrong/relative-path.git', '') | false Gitlab::Git::Repository.new('broken', 'wrong/relative-path.git', '', 'group/project') | false
end end
with_them do with_them do
......
...@@ -19,8 +19,8 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -19,8 +19,8 @@ describe Gitlab::Git::Repository, :seed_helper do
end end
end end
let(:mutable_repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') } let(:mutable_repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '', 'group/project') }
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:repository_path) { File.join(TestEnv.repos_path, repository.relative_path) } let(:repository_path) { File.join(TestEnv.repos_path, repository.relative_path) }
let(:repository_rugged) { Rugged::Repository.new(repository_path) } let(:repository_rugged) { Rugged::Repository.new(repository_path) }
let(:storage_path) { TestEnv.repos_path } let(:storage_path) { TestEnv.repos_path }
...@@ -434,13 +434,13 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -434,13 +434,13 @@ describe Gitlab::Git::Repository, :seed_helper do
describe '#fetch_repository_as_mirror' do describe '#fetch_repository_as_mirror' do
let(:new_repository) do let(:new_repository) do
Gitlab::Git::Repository.new('default', 'my_project.git', '') Gitlab::Git::Repository.new('default', 'my_project.git', '', 'group/project')
end end
subject { new_repository.fetch_repository_as_mirror(repository) } subject { new_repository.fetch_repository_as_mirror(repository) }
before do before do
Gitlab::Shell.new.create_repository('default', 'my_project') Gitlab::Shell.new.create_repository('default', 'my_project', 'group/project')
end end
after do after do
...@@ -1230,7 +1230,7 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -1230,7 +1230,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end end
describe '#gitattribute' do describe '#gitattribute' do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_GITATTRIBUTES_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_GITATTRIBUTES_REPO_PATH, '', 'group/project') }
after do after do
ensure_seeds ensure_seeds
...@@ -1249,7 +1249,7 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -1249,7 +1249,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end end
context 'without gitattributes file' do context 'without gitattributes file' do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
it 'returns nil' do it 'returns nil' do
expect(repository.gitattribute("README.md", 'gitlab-language')).to eq(nil) expect(repository.gitattribute("README.md", 'gitlab-language')).to eq(nil)
...@@ -1513,7 +1513,7 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -1513,7 +1513,7 @@ describe Gitlab::Git::Repository, :seed_helper do
context 'repository does not exist' do context 'repository does not exist' do
it 'raises NoRepository and does not call Gitaly WriteConfig' do it 'raises NoRepository and does not call Gitaly WriteConfig' do
repository = Gitlab::Git::Repository.new('default', 'does/not/exist.git', '') repository = Gitlab::Git::Repository.new('default', 'does/not/exist.git', '', 'group/project')
expect(repository.gitaly_repository_client).not_to receive(:write_config) expect(repository.gitaly_repository_client).not_to receive(:write_config)
...@@ -1803,7 +1803,7 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -1803,7 +1803,7 @@ describe Gitlab::Git::Repository, :seed_helper do
out: '/dev/null', out: '/dev/null',
err: '/dev/null') err: '/dev/null')
empty_repo = described_class.new('default', 'empty-repo.git', '') empty_repo = described_class.new('default', 'empty-repo.git', '', 'group/empty-repo')
expect(empty_repo.checksum).to eq '0000000000000000000000000000000000000000' expect(empty_repo.checksum).to eq '0000000000000000000000000000000000000000'
end end
...@@ -1818,13 +1818,13 @@ describe Gitlab::Git::Repository, :seed_helper do ...@@ -1818,13 +1818,13 @@ describe Gitlab::Git::Repository, :seed_helper do
File.truncate(File.join(storage_path, 'non-valid.git/HEAD'), 0) File.truncate(File.join(storage_path, 'non-valid.git/HEAD'), 0)
non_valid = described_class.new('default', 'non-valid.git', '') non_valid = described_class.new('default', 'non-valid.git', '', 'a/non-valid')
expect { non_valid.checksum }.to raise_error(Gitlab::Git::Repository::InvalidRepository) expect { non_valid.checksum }.to raise_error(Gitlab::Git::Repository::InvalidRepository)
end end
it 'raises Gitlab::Git::Repository::NoRepository error when there is no repo' do it 'raises Gitlab::Git::Repository::NoRepository error when there is no repo' do
broken_repo = described_class.new('default', 'a/path.git', '') broken_repo = described_class.new('default', 'a/path.git', '', 'a/path')
expect { broken_repo.checksum }.to raise_error(Gitlab::Git::Repository::NoRepository) expect { broken_repo.checksum }.to raise_error(Gitlab::Git::Repository::NoRepository)
end end
......
require "spec_helper" require "spec_helper"
describe Gitlab::Git::Tag, :seed_helper do describe Gitlab::Git::Tag, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
describe '#tags' do describe '#tags' do
describe 'first tag' do describe 'first tag' do
......
require "spec_helper" require "spec_helper"
describe Gitlab::Git::Tree, :seed_helper do describe Gitlab::Git::Tree, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
context :repo do context :repo do
let(:tree) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID) } let(:tree) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID) }
......
...@@ -33,7 +33,7 @@ describe Gitlab::GitalyClient::RemoteService do ...@@ -33,7 +33,7 @@ describe Gitlab::GitalyClient::RemoteService do
end end
describe '#fetch_internal_remote' do describe '#fetch_internal_remote' do
let(:remote_repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') } let(:remote_repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '', 'group/project') }
it 'sends an fetch_internal_remote message and returns the result value' do it 'sends an fetch_internal_remote message and returns the result value' do
expect_any_instance_of(Gitaly::RemoteService::Stub) expect_any_instance_of(Gitaly::RemoteService::Stub)
......
...@@ -7,6 +7,7 @@ describe Gitlab::GitalyClient::Util do ...@@ -7,6 +7,7 @@ describe Gitlab::GitalyClient::Util do
let(:gl_repository) { 'project-1' } let(:gl_repository) { 'project-1' }
let(:git_object_directory) { '.git/objects' } let(:git_object_directory) { '.git/objects' }
let(:git_alternate_object_directory) { ['/dir/one', '/dir/two'] } let(:git_alternate_object_directory) { ['/dir/one', '/dir/two'] }
let(:gl_project_path) { 'namespace/myproject' }
let(:git_env) do let(:git_env) do
{ {
'GIT_OBJECT_DIRECTORY_RELATIVE' => git_object_directory, 'GIT_OBJECT_DIRECTORY_RELATIVE' => git_object_directory,
...@@ -15,7 +16,7 @@ describe Gitlab::GitalyClient::Util do ...@@ -15,7 +16,7 @@ describe Gitlab::GitalyClient::Util do
end end
subject do subject do
described_class.repository(repository_storage, relative_path, gl_repository) described_class.repository(repository_storage, relative_path, gl_repository, gl_project_path)
end end
it 'creates a Gitaly::Repository with the given data' do it 'creates a Gitaly::Repository with the given data' do
...@@ -27,6 +28,7 @@ describe Gitlab::GitalyClient::Util do ...@@ -27,6 +28,7 @@ describe Gitlab::GitalyClient::Util do
expect(subject.gl_repository).to eq(gl_repository) expect(subject.gl_repository).to eq(gl_repository)
expect(subject.git_object_directory).to eq(git_object_directory) expect(subject.git_object_directory).to eq(git_object_directory)
expect(subject.git_alternate_object_directories).to eq(git_alternate_object_directory) expect(subject.git_alternate_object_directories).to eq(git_alternate_object_directory)
expect(subject.gl_project_path).to eq(gl_project_path)
end end
end end
end end
...@@ -5,6 +5,14 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do ...@@ -5,6 +5,14 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
let(:import_state) { double(:import_state) } let(:import_state) { double(:import_state) }
let(:client) { double(:client) } let(:client) { double(:client) }
let(:wiki) do
double(
:wiki,
disk_path: 'foo.wiki',
full_path: 'group/foo.wiki'
)
end
let(:project) do let(:project) do
double( double(
:project, :project,
...@@ -15,7 +23,9 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do ...@@ -15,7 +23,9 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
repository: repository, repository: repository,
create_wiki: true, create_wiki: true,
import_state: import_state, import_state: import_state,
lfs_enabled?: true full_path: 'group/foo',
lfs_enabled?: true,
wiki: wiki
) )
end end
...@@ -195,7 +205,7 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do ...@@ -195,7 +205,7 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
it 'imports the wiki repository' do it 'imports the wiki repository' do
expect(importer.gitlab_shell) expect(importer.gitlab_shell)
.to receive(:import_repository) .to receive(:import_repository)
.with('foo', 'foo.wiki', 'foo.wiki.git') .with('foo', 'foo.wiki', 'foo.wiki.git', 'group/foo.wiki')
expect(importer.import_wiki_repository).to eq(true) expect(importer.import_wiki_repository).to eq(true)
end end
......
...@@ -10,11 +10,17 @@ describe Gitlab::LegacyGithubImport::WikiFormatter do ...@@ -10,11 +10,17 @@ describe Gitlab::LegacyGithubImport::WikiFormatter do
subject(:wiki) { described_class.new(project) } subject(:wiki) { described_class.new(project) }
describe '#disk_path' do describe '#disk_path' do
it 'appends .wiki to project path' do it 'appends .wiki to disk path' do
expect(wiki.disk_path).to eq project.wiki.disk_path expect(wiki.disk_path).to eq project.wiki.disk_path
end end
end end
describe '#full_path' do
it 'appends .wiki to project path' do
expect(wiki.full_path).to eq project.wiki.full_path
end
end
describe '#import_url' do describe '#import_url' do
it 'returns URL of the wiki repository' do it 'returns URL of the wiki repository' do
expect(wiki.import_url).to eq 'https://xxx@github.com/gitlabhq/sample.gitlabhq.wiki.git' expect(wiki.import_url).to eq 'https://xxx@github.com/gitlabhq/sample.gitlabhq.wiki.git'
......
...@@ -412,7 +412,7 @@ describe Gitlab::Shell do ...@@ -412,7 +412,7 @@ describe Gitlab::Shell do
end end
it 'creates a repository' do it 'creates a repository' do
expect(gitlab_shell.create_repository(repository_storage, repo_name)).to be_truthy expect(gitlab_shell.create_repository(repository_storage, repo_name, repo_name)).to be_truthy
expect(File.stat(created_path).mode & 0o777).to eq(0o770) expect(File.stat(created_path).mode & 0o777).to eq(0o770)
...@@ -427,7 +427,7 @@ describe Gitlab::Shell do ...@@ -427,7 +427,7 @@ describe Gitlab::Shell do
# should cause #create_repository to fail. # should cause #create_repository to fail.
FileUtils.touch(created_path) FileUtils.touch(created_path)
expect(gitlab_shell.create_repository(repository_storage, repo_name)).to be_falsy expect(gitlab_shell.create_repository(repository_storage, repo_name, repo_name)).to be_falsy
end end
end end
...@@ -474,13 +474,10 @@ describe Gitlab::Shell do ...@@ -474,13 +474,10 @@ describe Gitlab::Shell do
end end
describe '#fork_repository' do describe '#fork_repository' do
let(:target_project) { create(:project) }
subject do subject do
gitlab_shell.fork_repository( gitlab_shell.fork_repository(project, target_project)
project.repository_storage,
project.disk_path,
'nfs-file05',
'fork/path'
)
end end
it 'returns true when the command succeeds' do it 'returns true when the command succeeds' do
...@@ -505,7 +502,7 @@ describe Gitlab::Shell do ...@@ -505,7 +502,7 @@ describe Gitlab::Shell do
it 'returns true when the command succeeds' do it 'returns true when the command succeeds' do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:import_repository).with(import_url) expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:import_repository).with(import_url)
result = gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url) result = gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url, project.full_path)
expect(result).to be_truthy expect(result).to be_truthy
end end
...@@ -516,7 +513,7 @@ describe Gitlab::Shell do ...@@ -516,7 +513,7 @@ describe Gitlab::Shell do
expect_any_instance_of(Gitlab::Shell::GitalyGitlabProjects).to receive(:output) { 'error'} expect_any_instance_of(Gitlab::Shell::GitalyGitlabProjects).to receive(:output) { 'error'}
expect do expect do
gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url) gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url, project.full_path)
end.to raise_error(Gitlab::Shell::Error, "error") end.to raise_error(Gitlab::Shell::Error, "error")
end end
end end
......
...@@ -1765,7 +1765,7 @@ describe Project do ...@@ -1765,7 +1765,7 @@ describe Project do
context 'using a regular repository' do context 'using a regular repository' do
it 'creates the repository' do it 'creates the repository' do
expect(shell).to receive(:create_repository) expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path) .with(project.repository_storage, project.disk_path, project.full_path)
.and_return(true) .and_return(true)
expect(project.repository).to receive(:after_create) expect(project.repository).to receive(:after_create)
...@@ -1775,7 +1775,7 @@ describe Project do ...@@ -1775,7 +1775,7 @@ describe Project do
it 'adds an error if the repository could not be created' do it 'adds an error if the repository could not be created' do
expect(shell).to receive(:create_repository) expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path) .with(project.repository_storage, project.disk_path, project.full_path)
.and_return(false) .and_return(false)
expect(project.repository).not_to receive(:after_create) expect(project.repository).not_to receive(:after_create)
...@@ -1808,7 +1808,7 @@ describe Project do ...@@ -1808,7 +1808,7 @@ describe Project do
.and_return(false) .and_return(false)
allow(shell).to receive(:create_repository) allow(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path) .with(project.repository_storage, project.disk_path, project.full_path)
.and_return(true) .and_return(true)
expect(project).to receive(:create_repository).with(force: true) expect(project).to receive(:create_repository).with(force: true)
...@@ -1832,7 +1832,7 @@ describe Project do ...@@ -1832,7 +1832,7 @@ describe Project do
.and_return(false) .and_return(false)
expect(shell).to receive(:create_repository) expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path) .with(project.repository_storage, project.disk_path, project.full_path)
.and_return(true) .and_return(true)
project.ensure_repository project.ensure_repository
......
...@@ -7,7 +7,7 @@ describe ProjectWiki do ...@@ -7,7 +7,7 @@ describe ProjectWiki do
let(:repository) { project.repository } let(:repository) { project.repository }
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:project_wiki) { described_class.new(project, user) } let(:project_wiki) { described_class.new(project, user) }
let(:raw_repository) { Gitlab::Git::Repository.new(project.repository_storage, subject.disk_path + '.git', 'foo') } let(:raw_repository) { Gitlab::Git::Repository.new(project.repository_storage, subject.disk_path + '.git', 'foo', 'group/project.wiki') }
let(:commit) { project_wiki.repository.head_commit } let(:commit) { project_wiki.repository.head_commit }
subject { project_wiki } subject { project_wiki }
...@@ -75,7 +75,7 @@ describe ProjectWiki do ...@@ -75,7 +75,7 @@ describe ProjectWiki do
# Create a fresh project which will not have a wiki # Create a fresh project which will not have a wiki
project_wiki = described_class.new(create(:project), user) project_wiki = described_class.new(create(:project), user)
gitlab_shell = double(:gitlab_shell) gitlab_shell = double(:gitlab_shell)
allow(gitlab_shell).to receive(:create_repository) allow(gitlab_shell).to receive(:create_wiki_repository)
allow(project_wiki).to receive(:gitlab_shell).and_return(gitlab_shell) allow(project_wiki).to receive(:gitlab_shell).and_return(gitlab_shell)
expect { project_wiki.send(:wiki) }.to raise_exception(ProjectWiki::CouldNotCreateWikiError) expect { project_wiki.send(:wiki) }.to raise_exception(ProjectWiki::CouldNotCreateWikiError)
......
...@@ -2291,6 +2291,7 @@ describe Repository do ...@@ -2291,6 +2291,7 @@ describe Repository do
expect(subject).to be_a(Gitlab::Git::Repository) expect(subject).to be_a(Gitlab::Git::Repository)
expect(subject.relative_path).to eq(project.disk_path + '.git') expect(subject.relative_path).to eq(project.disk_path + '.git')
expect(subject.gl_repository).to eq("project-#{project.id}") expect(subject.gl_repository).to eq("project-#{project.id}")
expect(subject.gl_project_path).to eq(project.full_path)
end end
context 'with a wiki repository' do context 'with a wiki repository' do
...@@ -2300,6 +2301,7 @@ describe Repository do ...@@ -2300,6 +2301,7 @@ describe Repository do
expect(subject).to be_a(Gitlab::Git::Repository) expect(subject).to be_a(Gitlab::Git::Repository)
expect(subject.relative_path).to eq(project.disk_path + '.wiki.git') expect(subject.relative_path).to eq(project.disk_path + '.wiki.git')
expect(subject.gl_repository).to eq("wiki-#{project.id}") expect(subject.gl_repository).to eq("wiki-#{project.id}")
expect(subject.gl_project_path).to eq(project.full_path)
end end
end end
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe BlobPresenter, :seed_helper do describe BlobPresenter, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
let(:git_blob) do let(:git_blob) do
Gitlab::Git::Blob.find( Gitlab::Git::Blob.find(
......
...@@ -116,7 +116,7 @@ describe Projects::CreateService, '#execute' do ...@@ -116,7 +116,7 @@ describe Projects::CreateService, '#execute' do
def wiki_repo(project) def wiki_repo(project)
relative_path = ProjectWiki.new(project).disk_path + '.git' relative_path = ProjectWiki.new(project).disk_path + '.git'
Gitlab::Git::Repository.new(project.repository_storage, relative_path, 'foobar') Gitlab::Git::Repository.new(project.repository_storage, relative_path, 'foobar', project.full_path)
end end
end end
...@@ -198,7 +198,7 @@ describe Projects::CreateService, '#execute' do ...@@ -198,7 +198,7 @@ describe Projects::CreateService, '#execute' do
context 'with legacy storage' do context 'with legacy storage' do
before do before do
gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing") gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing", 'group/project')
end end
after do after do
...@@ -234,7 +234,7 @@ describe Projects::CreateService, '#execute' do ...@@ -234,7 +234,7 @@ describe Projects::CreateService, '#execute' do
end end
before do before do
gitlab_shell.create_repository(repository_storage, hashed_path) gitlab_shell.create_repository(repository_storage, hashed_path, 'group/project')
end end
after do after do
......
...@@ -119,7 +119,7 @@ describe Projects::ForkService do ...@@ -119,7 +119,7 @@ describe Projects::ForkService do
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path } let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path }
before do before do
gitlab_shell.create_repository(repository_storage, "#{@to_user.namespace.full_path}/#{@from_project.path}") gitlab_shell.create_repository(repository_storage, "#{@to_user.namespace.full_path}/#{@from_project.path}", "#{@to_user.namespace.full_path}/#{@from_project.path}")
end end
after do after do
......
...@@ -201,7 +201,7 @@ describe Projects::TransferService do ...@@ -201,7 +201,7 @@ describe Projects::TransferService do
before do before do
group.add_owner(user) group.add_owner(user)
unless gitlab_shell.create_repository(repository_storage, "#{group.full_path}/#{project.path}") unless gitlab_shell.create_repository(repository_storage, "#{group.full_path}/#{project.path}", project.full_path)
raise 'failed to add repository' raise 'failed to add repository'
end end
......
...@@ -232,7 +232,7 @@ describe Projects::UpdateService do ...@@ -232,7 +232,7 @@ describe Projects::UpdateService do
let(:project) { create(:project, :legacy_storage, :repository, creator: user, namespace: user.namespace) } let(:project) { create(:project, :legacy_storage, :repository, creator: user, namespace: user.namespace) }
before do before do
gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing") gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing", user.namespace.full_path)
end end
after do after do
......
...@@ -24,12 +24,7 @@ describe RepositoryForkWorker do ...@@ -24,12 +24,7 @@ describe RepositoryForkWorker do
end end
def expect_fork_repository def expect_fork_repository
expect(shell).to receive(:fork_repository).with( expect(shell).to receive(:fork_repository).with(project, forked_project)
'default',
project.disk_path,
forked_project.repository_storage,
forked_project.disk_path
)
end end
describe 'when a worker was reset without cleanup' do describe 'when a worker was reset without cleanup' do
......
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