diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 12:09:12 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 12:09:12 +0000 |
commit | cbfe03ae04a52d9825ff7cbeccdfe5d313adf6a2 (patch) | |
tree | e4879b35d019d3bbba1689f3ac4c48b81bf7b451 /app/models/project_wiki.rb | |
parent | 3fd97b4bba24ca412112aad025a38a32c7a6cf8c (diff) | |
download | gitlab-ce-cbfe03ae04a52d9825ff7cbeccdfe5d313adf6a2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/project_wiki.rb')
-rw-r--r-- | app/models/project_wiki.rb | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 8ed7811b468..f8528a41634 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true class ProjectWiki - include Gitlab::ShellAdapter include Storage::LegacyProjectWiki + include Gitlab::Utils::StrongMemoize MARKUPS = { 'Markdown' => :markdown, @@ -47,7 +47,7 @@ class ProjectWiki end def url_to_repo - gitlab_shell.url_to_repo(full_path) + Gitlab::Shell.url_to_repo(full_path) end def ssh_url_to_repo @@ -64,14 +64,15 @@ class ProjectWiki # Returns the Gitlab::Git::Wiki object. def wiki - @wiki ||= begin - gl_repository = Gitlab::GlRepository::WIKI.identifier_for_container(project) - raw_repository = Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', gl_repository, full_path) + strong_memoize(:wiki) do + repository.create_if_not_exists + raise CouldNotCreateWikiError unless repository_exists? - create_repo!(raw_repository) unless raw_repository.exists? - - Gitlab::Git::Wiki.new(raw_repository) + Gitlab::Git::Wiki.new(repository.raw) end + rescue => err + Gitlab::ErrorTracking.track_exception(err, project_wiki: { project_id: project.id, full_path: full_path, disk_path: disk_path }) + raise CouldNotCreateWikiError end def repository_exists? @@ -193,14 +194,6 @@ class ProjectWiki private - def create_repo!(raw_repository) - gitlab_shell.create_wiki_repository(project) - - raise CouldNotCreateWikiError unless raw_repository.exists? - - repository.after_create - end - def commit_details(action, message = nil, title = nil) commit_message = message.presence || default_message(action, title) git_user = Gitlab::Git::User.from_gitlab(@user) |