diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/models/wiki.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/models/wiki.rb')
-rw-r--r-- | app/models/wiki.rb | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/app/models/wiki.rb b/app/models/wiki.rb index 32d70fcd3b7..c9cb3b0b796 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -227,32 +227,22 @@ class Wiki end def create_page(title, content, format = :markdown, message = nil) - if Feature.enabled?(:gitaly_replace_wiki_create_page, container, type: :undefined) - with_valid_format(format) do |default_extension| - if file_exists_by_regex?(title) - raise_duplicate_page_error! - end - - capture_git_error(:created) do - create_wiki_repository unless repository_exists? - sanitized_path = sluggified_full_path(title, default_extension) - repository.create_file(user, sanitized_path, content, **multi_commit_options(:created, message, title)) - repository.expire_status_cache if repository.empty? - after_wiki_activity - - true - rescue Gitlab::Git::Index::IndexError - raise_duplicate_page_error! - end + with_valid_format(format) do |default_extension| + if file_exists_by_regex?(title) + raise_duplicate_page_error! end - else - commit = commit_details(:created, message, title) - wiki.write_page(title, format.to_sym, content, commit) - repository.expire_status_cache if repository.empty? - after_wiki_activity + capture_git_error(:created) do + create_wiki_repository unless repository_exists? + sanitized_path = sluggified_full_path(title, default_extension) + repository.create_file(user, sanitized_path, content, **multi_commit_options(:created, message, title)) + repository.expire_status_cache if repository.empty? + after_wiki_activity - true + true + rescue Gitlab::Git::Index::IndexError + raise_duplicate_page_error! + end end rescue Gitlab::Git::Wiki::DuplicatePageError => e @error_message = _("Duplicate page: %{error_message}" % { error_message: e.message }) @@ -395,17 +385,6 @@ class Wiki } end - def commit_details(action, message = nil, title = nil) - commit_message = build_commit_message(action, message, title) - git_user = Gitlab::Git::User.from_gitlab(user) - - Gitlab::Git::Wiki::CommitDetails.new(user.id, - git_user.username, - git_user.name, - git_user.email, - commit_message) - end - def build_commit_message(action, message, title) message.presence || default_message(action, title) end |