Add convenience methods for creating project and Wiki repositories

This makes it easier to access other project arguments in the future.
This commit is contained in:
Stan Hu 2019-01-17 13:50:18 -08:00
parent 1af22dbe5c
commit b103f61450
5 changed files with 12 additions and 4 deletions

View file

@ -1288,7 +1288,7 @@ class Project < ActiveRecord::Base
# Forked import is handled asynchronously
return if forked? && !force
if gitlab_shell.create_repository(repository_storage, disk_path, full_path)
if gitlab_shell.create_project_repository(self)
repository.after_create
true
else

View file

@ -175,7 +175,7 @@ class ProjectWiki
private
def create_repo!(raw_repository)
gitlab_shell.create_repository(project.repository_storage, disk_path, project.full_path)
gitlab_shell.create_wiki_repository(project)
raise CouldNotCreateWikiError unless raw_repository.exists?

View file

@ -93,7 +93,7 @@ module Backup
progress.puts "Error: #{e}".color(:red)
end
else
restore_repo_success = gitlab_shell.create_repository(project.repository_storage, project.disk_path, project.full_path)
restore_repo_success = gitlab_shell.create_project_repository(project)
end
if restore_repo_success

View file

@ -64,6 +64,14 @@ module Gitlab
end
end
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
#
# storage - the shard key

View file

@ -75,7 +75,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(:create_repository)
allow(gitlab_shell).to receive(:create_wiki_repository)
allow(project_wiki).to receive(:gitlab_shell).and_return(gitlab_shell)
expect { project_wiki.send(:wiki) }.to raise_exception(ProjectWiki::CouldNotCreateWikiError)