lib/caramelize/output_wiki/gollum.rb in caramelize-1.1.1 vs lib/caramelize/output_wiki/gollum.rb in caramelize-1.2.0

- old
+ new

@@ -1,21 +1,22 @@ +# frozen_string_literal: true + require 'gollum-lib' module Caramelize module OutputWiki class Gollum - attr_reader :wiki_path SUPPORTED_TARGET_MARKUP = %i[markdown textile rdoc creole media_wiki org pod re_structured_text ascii_doc].freeze # Initialize a new gollum-wiki-repository at the given path. def initialize(new_wiki_path) - # TODO use sanitized name as wiki-repository-title + # TODO: use sanitized name as wiki-repository-title @wiki_path = new_wiki_path - initialize_repository + initialize_repository unless File.exist?(wiki_path) end # Commit the given page into the gollum-wiki-repository. # Make sure the target markup is correct before calling this method. def commit_revision(page, markup) @@ -26,13 +27,13 @@ else gollum.write_page(page.path, markup, page.body, build_commit(page)) end end - def rename_page(page_title, rename) + def rename_page(page_title, new_title) gollum_page = gollum.page(page_title) - gollum.rename_page(gollum_page, rename, { message: 'Rename home page' }) + gollum.rename_page(gollum_page, new_title, { message: 'Rename home page' }) end # Commit all revisions of the given history into this gollum-wiki-repository. def commit_history(revisions, options = {}, &block) revisions.each_with_index do |page, index| @@ -51,12 +52,12 @@ end def build_commit(page) { message: page.commit_message, - name: page.author.name, - email: page.author.email, + name: page.author_name, + email: page.author_email, time: page.time } end private @@ -64,16 +65,15 @@ def build_namespace_overview(namespaces) ::Caramelize::Services::PageBuilder.build_namespace_overview(namespaces) end def gollum - @gollum ||= ::Gollum::Wiki.new(wiki_path, {repo_is_bare: true}) + @gollum ||= ::Gollum::Wiki.new(wiki_path, { repo_is_bare: true, ref: 'main' }) end def initialize_repository - return if File.exist?(wiki_path) Dir.mkdir(wiki_path) - #::Gollum::Git::Repo.new(wiki_path, { is_bare: true }) + # ::Gollum::Git::Repo.new(wiki_path, { is_bare: true }) ::Gollum::Git::Repo.init(wiki_path) end end end end