Merge branch 'fix/avoid-using-rugged-in-wiki-preview-slug' into 'master'
Avoid using Rugged in Gitlab::Git::Wiki#preview_slug See merge request gitlab-org/gitlab-ce!15054
This commit is contained in:
commit
aee7f0d0cb
1 changed files with 10 additions and 1 deletions
|
@ -8,6 +8,7 @@ module Gitlab
|
|||
{ name: name, email: email, message: message }
|
||||
end
|
||||
end
|
||||
PageBlob = Struct.new(:name)
|
||||
|
||||
def self.default_ref
|
||||
'master'
|
||||
|
@ -80,7 +81,15 @@ module Gitlab
|
|||
end
|
||||
|
||||
def preview_slug(title, format)
|
||||
gollum_wiki.preview_page(title, '', format).url_path
|
||||
# Adapted from gollum gem (Gollum::Wiki#preview_page) to avoid
|
||||
# using Rugged through a Gollum::Wiki instance
|
||||
page_class = Gollum::Page
|
||||
page = page_class.new(nil)
|
||||
ext = page_class.format_to_ext(format.to_sym)
|
||||
name = page_class.cname(title) + '.' + ext
|
||||
blob = PageBlob.new(name)
|
||||
page.populate(blob)
|
||||
page.url_path
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue