diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /app/models/wiki_page.rb | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r-- | app/models/wiki_page.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 63c60f5a89e..24b0b94eeb7 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -73,7 +73,7 @@ class WikiPage # The escaped URL path of this page. def slug - attributes[:slug].presence || wiki.wiki.preview_slug(title, format) + attributes[:slug].presence || ::Wiki.preview_slug(title, format) end alias_method :id, :slug # required to use build_stubbed @@ -99,6 +99,13 @@ class WikiPage attributes[:content] ||= page&.text_data end + def raw_content=(content) + return if page.nil? + + page.raw_data = content + attributes[:content] = page.text_data + end + # The hierarchy of the directory this page is contained in. def directory wiki.page_title_and_dir(slug)&.last.to_s @@ -118,7 +125,7 @@ class WikiPage def version return unless persisted? - @version ||= @page.version + @version ||= @page.version || last_version end def path @@ -138,7 +145,7 @@ class WikiPage default_per_page = Kaminari.config.default_per_page offset = [options[:page].to_i - 1, 0].max * options.fetch(:per_page, default_per_page) - wiki.repository.commits('HEAD', + wiki.repository.commits(wiki.default_branch, path: page.path, limit: options.fetch(:limit, default_per_page), offset: offset) @@ -147,11 +154,11 @@ class WikiPage def count_versions return [] unless persisted? - wiki.wiki.count_page_versions(page.path) + wiki.repository.count_commits(ref: wiki.default_branch, path: page.path) end def last_version - @last_version ||= versions(limit: 1).first + @last_version ||= wiki.repository.last_commit_for_path(wiki.default_branch, page.path) if page end def last_commit_sha |