Commit 82b6e537 authored by Stan Hu's avatar Stan Hu 🔴

Send project name with Gitaly repository requests

When hashed storage is in use, it's helpful to have the project
name associated with the request.

Closes gitaly#1394
parent d8e24e9d
...@@ -96,7 +96,8 @@ class PoolRepository < ActiveRecord::Base ...@@ -96,7 +96,8 @@ 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.path_with_namespace)
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_repository(repository_storage, disk_path, full_path)
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_repository(project.repository_storage, disk_path, project.full_path)
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_repository(project.repository_storage, project.disk_path, project.import_url, project.full_path)
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,21 @@ class RepositoryForkWorker ...@@ -15,19 +15,21 @@ 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(
target_project.repository_storage, target_project.disk_path) source_project.repository_storage, source_project.disk_path, source_project.full_path,
raise "Unable to fork project #{target_project.id} for repository #{source_disk_path} -> #{target_project.disk_path}" unless result target_project.repository_storage, target_project.disk_path, target_project.full_path)
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_repository(project.repository_storage, project.disk_path, project.full_path)
end end
if restore_repo_success if restore_repo_success
......
...@@ -67,7 +67,7 @@ module Gitlab ...@@ -67,7 +67,7 @@ module Gitlab
disk_path = project.wiki.disk_path disk_path = project.wiki.disk_path
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, disk_path, import_url) gitlab_shell.import_repository(project.repository_storage, disk_path, import_url, project.full_path)
rescue StandardError => e rescue StandardError => e
errors << { type: :wiki, errors: e.message } errors << { type: :wiki, errors: e.message }
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_name
def initialize(storage, relative_path, source_repository) def initialize(storage, relative_path, source_repository, gl_project_name)
@storage = storage @storage = storage
@relative_path = relative_path @relative_path = relative_path
@source_repository = source_repository @source_repository = source_repository
@gl_project_name = gl_project_name
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_name)
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_name)
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_name
# 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_name)
@storage = storage @storage = storage
@relative_path = relative_path @relative_path = relative_path
@gl_repository = gl_repository @gl_repository = gl_repository
@gl_project_name = gl_project_name
@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_name)
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_name)
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_name: gl_project_name
) )
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_name)
end end
end end
end end
......
...@@ -59,7 +59,7 @@ module Gitlab ...@@ -59,7 +59,7 @@ module Gitlab
def import_wiki_repository def import_wiki_repository
wiki_path = "#{project.disk_path}.wiki" wiki_path = "#{project.disk_path}.wiki"
gitlab_shell.import_repository(project.repository_storage, wiki_path, wiki_url) gitlab_shell.import_repository(project.repository_storage, wiki_path, wiki_url, project.full_path)
true true
rescue Gitlab::Shell::Error => e rescue Gitlab::Shell::Error => e
......
...@@ -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_repository(project.repository_storage, wiki.disk_path, wiki.import_url, project.wiki.full_path)
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,
......
...@@ -68,15 +68,16 @@ module Gitlab ...@@ -68,15 +68,16 @@ module Gitlab
# #
# storage - the shard key # storage - the shard key
# name - project disk path # name - project disk path
# gl_project_name - 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, name, gl_project_name)
relative_path = name.dup relative_path = name.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, '') repository = Gitlab::Git::Repository.new(storage, relative_path, '', gl_project_name)
wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository } wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository }
true true
...@@ -94,13 +95,13 @@ module Gitlab ...@@ -94,13 +95,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_name)
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_name)
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
...@@ -132,11 +133,13 @@ module Gitlab ...@@ -132,11 +133,13 @@ module Gitlab
# #
# Ex. # Ex.
# fork_repository("nfs-file06", "gitlab/gitlab-ci", "nfs-file07", "new-namespace/gitlab-ci") # 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) def fork_repository(
forked_from_storage, forked_from_disk_path, forked_from_project_name,
forked_to_storage, forked_to_disk_path, forked_to_project_name)
forked_from_relative_path = "#{forked_from_disk_path}.git" forked_from_relative_path = "#{forked_from_disk_path}.git"
fork_args = [forked_to_storage, "#{forked_to_disk_path}.git"] fork_args = [forked_to_storage, "#{forked_to_disk_path}.git", forked_to_project_name]
GitalyGitlabProjects.new(forked_from_storage, forked_from_relative_path).fork_repository(*fork_args) GitalyGitlabProjects.new(forked_from_storage, forked_from_relative_path, forked_from_project_name).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 +400,17 @@ module Gitlab ...@@ -397,16 +400,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_name
def initialize(shard_name, repository_relative_path) def initialize(shard_name, repository_relative_path, gl_project_name)
@shard_name = shard_name @shard_name = shard_name
@repository_relative_path = repository_relative_path @repository_relative_path = repository_relative_path
@output = '' @output = ''
@gl_project_name = gl_project_name
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_name)
Gitlab::GitalyClient::RepositoryService.new(raw_repository).import_repository(source) Gitlab::GitalyClient::RepositoryService.new(raw_repository).import_repository(source)
true true
...@@ -415,9 +419,9 @@ module Gitlab ...@@ -415,9 +419,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_name)
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'
......
...@@ -230,7 +230,8 @@ describe Gitlab::BitbucketImport::Importer do ...@@ -230,7 +230,8 @@ describe Gitlab::BitbucketImport::Importer do
expect(importer.gitlab_shell).to receive(:import_repository).with( expect(importer.gitlab_shell).to receive(:import_repository).with(
project.repository_storage, project.repository_storage,
project.wiki.disk_path, project.wiki.disk_path,
project.import_url + '/wiki' project.import_url + '/wiki',
project.full_path
) )
importer.execute importer.execute
......
...@@ -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