Skip to content
Snippets Groups Projects
Unverified Commit 77f0906e authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg
Browse files

Change Gitlab::Shell#add_namespace to #create_namespace

Prior to this change, this method was called add_namespace, which broke
the CRUD convention and made it harder to grep for what I was looking
for. Given the change was a find and replace kind of fix, this was
changed without opening an issue and on another feature branch.

If more dynamic calls are made to add_namespace, these could've been
missed which might lead to incorrect bahaviour. However, going through
the commit log it seems thats not the case.
parent 5ae91f32
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1083,7 +1083,7 @@ class Project < ActiveRecord::Base
# Forked import is handled asynchronously
return if forked? && !force
 
if gitlab_shell.add_repository(repository_storage, disk_path)
if gitlab_shell.create_repository(repository_storage, disk_path)
repository.after_create
true
else
Loading
Loading
Loading
Loading
@@ -169,7 +169,7 @@ class ProjectWiki
private
 
def create_repo!(raw_repository)
gitlab_shell.add_repository(project.repository_storage, disk_path)
gitlab_shell.create_repository(project.repository_storage, disk_path)
 
raise CouldNotCreateWikiError unless raw_repository.exists?
 
Loading
Loading
Loading
Loading
@@ -69,9 +69,9 @@ module Gitlab
# name - project disk path
#
# Ex.
# add_repository("/path/to/storage", "gitlab/gitlab-ci")
# create_repository("/path/to/storage", "gitlab/gitlab-ci")
#
def add_repository(storage, name)
def create_repository(storage, name)
relative_path = name.dup
relative_path << '.git' unless relative_path.end_with?('.git')
 
Loading
Loading
Loading
Loading
@@ -69,7 +69,7 @@ namespace :gitlab do
if File.exist?(path_to_repo)
print '-'
else
if Gitlab::Shell.new.add_repository(project.repository_storage,
if Gitlab::Shell.new.create_repository(project.repository_storage,
project.disk_path)
print '.'
else
Loading
Loading
Loading
Loading
@@ -61,7 +61,7 @@ describe ::Gitlab::BareRepositoryImport::Repository do
let(:wiki_path) { File.join(root_path, "#{hashed_path}.wiki.git") }
 
before do
gitlab_shell.add_repository(repository_storage, hashed_path)
gitlab_shell.create_repository(repository_storage, hashed_path)
repository = Rugged::Repository.new(repo_path)
repository.config['gitlab.fullpath'] = 'to/repo'
end
Loading
Loading
Loading
Loading
@@ -681,7 +681,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
subject { new_repository.fetch_repository_as_mirror(repository) }
 
before do
Gitlab::Shell.new.add_repository('default', 'my_project')
Gitlab::Shell.new.create_repository('default', 'my_project')
end
 
after do
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ describe Gitlab::Shell do
 
it { is_expected.to respond_to :add_key }
it { is_expected.to respond_to :remove_key }
it { is_expected.to respond_to :add_repository }
it { is_expected.to respond_to :create_repository }
it { is_expected.to respond_to :remove_repository }
it { is_expected.to respond_to :fork_repository }
 
Loading
Loading
@@ -402,8 +402,8 @@ describe Gitlab::Shell do
allow(Gitlab.config.gitlab_shell).to receive(:git_timeout).and_return(800)
end
 
describe '#add_repository' do
shared_examples '#add_repository' do
describe '#create_repository' do
shared_examples '#create_repository' do
let(:repository_storage) { 'default' }
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage]['path'] }
let(:repo_name) { 'project/path' }
Loading
Loading
@@ -414,7 +414,7 @@ describe Gitlab::Shell do
end
 
it 'creates a repository' do
expect(gitlab_shell.add_repository(repository_storage, repo_name)).to be_truthy
expect(gitlab_shell.create_repository(repository_storage, repo_name)).to be_truthy
 
expect(File.stat(created_path).mode & 0o777).to eq(0o770)
 
Loading
Loading
@@ -426,19 +426,19 @@ describe Gitlab::Shell do
it 'returns false when the command fails' do
FileUtils.mkdir_p(File.dirname(created_path))
# This file will block the creation of the repo's .git directory. That
# should cause #add_repository to fail.
# should cause #create_repository to fail.
FileUtils.touch(created_path)
 
expect(gitlab_shell.add_repository(repository_storage, repo_name)).to be_falsy
expect(gitlab_shell.create_repository(repository_storage, repo_name)).to be_falsy
end
end
 
context 'with gitaly' do
it_behaves_like '#add_repository'
it_behaves_like '#create_repository'
end
 
context 'without gitaly', :skip_gitaly_mock do
it_behaves_like '#add_repository'
it_behaves_like '#create_repository'
end
end
 
Loading
Loading
Loading
Loading
@@ -1378,7 +1378,7 @@ describe Project do
 
context 'using a regular repository' do
it 'creates the repository' do
expect(shell).to receive(:add_repository)
expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path)
.and_return(true)
 
Loading
Loading
@@ -1388,7 +1388,7 @@ describe Project do
end
 
it 'adds an error if the repository could not be created' do
expect(shell).to receive(:add_repository)
expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path)
.and_return(false)
 
Loading
Loading
@@ -1402,7 +1402,7 @@ describe Project do
context 'using a forked repository' do
it 'does nothing' do
expect(project).to receive(:forked?).and_return(true)
expect(shell).not_to receive(:add_repository)
expect(shell).not_to receive(:create_repository)
 
project.create_repository
end
Loading
Loading
@@ -1421,7 +1421,7 @@ describe Project do
allow(project).to receive(:repository_exists?)
.and_return(false)
 
allow(shell).to receive(:add_repository)
allow(shell).to receive(:create_repository)
.with(project.repository_storage_path, project.disk_path)
.and_return(true)
 
Loading
Loading
@@ -1445,7 +1445,7 @@ describe Project do
allow(project).to receive(:repository_exists?)
.and_return(false)
 
expect(shell).to receive(:add_repository)
expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path)
.and_return(true)
 
Loading
Loading
Loading
Loading
@@ -74,7 +74,7 @@ describe ProjectWiki do
# Create a fresh project which will not have a wiki
project_wiki = described_class.new(create(:project), user)
gitlab_shell = double(:gitlab_shell)
allow(gitlab_shell).to receive(:add_repository)
allow(gitlab_shell).to receive(:create_repository)
allow(project_wiki).to receive(:gitlab_shell).and_return(gitlab_shell)
 
expect { project_wiki.send(:wiki) }.to raise_exception(ProjectWiki::CouldNotCreateWikiError)
Loading
Loading
Loading
Loading
@@ -164,7 +164,7 @@ describe Projects::CreateService, '#execute' do
 
context 'with legacy storage' do
before do
gitlab_shell.add_repository(repository_storage, "#{user.namespace.full_path}/existing")
gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing")
end
 
after do
Loading
Loading
@@ -200,7 +200,7 @@ describe Projects::CreateService, '#execute' do
end
 
before do
gitlab_shell.add_repository(repository_storage, hashed_path)
gitlab_shell.create_repository(repository_storage, hashed_path)
end
 
after do
Loading
Loading
Loading
Loading
@@ -108,7 +108,7 @@ describe Projects::ForkService do
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage]['path'] }
 
before do
gitlab_shell.add_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}")
end
 
after do
Loading
Loading
Loading
Loading
@@ -151,7 +151,7 @@ describe Projects::TransferService do
before do
group.add_owner(user)
 
unless gitlab_shell.add_repository(repository_storage, "#{group.full_path}/#{project.path}")
unless gitlab_shell.create_repository(repository_storage, "#{group.full_path}/#{project.path}")
raise 'failed to add repository'
end
 
Loading
Loading
Loading
Loading
@@ -196,7 +196,7 @@ describe Projects::UpdateService do
let(:project) { create(:project, :legacy_storage, :repository, creator: user, namespace: user.namespace) }
 
before do
gitlab_shell.add_repository(repository_storage, "#{user.namespace.full_path}/existing")
gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing")
end
 
after do
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