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:
Sean McGivern 2017-10-27 13:28:20 +00:00
commit aee7f0d0cb
1 changed files with 10 additions and 1 deletions

View File

@ -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