cache the ref => sha lookup
This commit is contained in:
+4
-5
@@ -246,15 +246,14 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns a Gollum::Page or nil if the page could not be found.
|
# Returns a Gollum::Page or nil if the page could not be found.
|
||||||
def find(name, version)
|
def find(name, version)
|
||||||
if commit = @wiki.repo.commit(version)
|
map = @wiki.tree_map_for(version)
|
||||||
map = @wiki.tree_map_for(commit.id)
|
|
||||||
if page = find_page_in_tree(map, name)
|
if page = find_page_in_tree(map, name)
|
||||||
page.version = commit
|
sha = @wiki.ref_map[version] || version
|
||||||
|
page.version = Grit::Commit.create(@wiki.repo, :id => sha)
|
||||||
page
|
page
|
||||||
end
|
end
|
||||||
|
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Find a page in a given tree.
|
# Find a page in a given tree.
|
||||||
#
|
#
|
||||||
# map - The Array tree map from Wiki#tree_map.
|
# map - The Array tree map from Wiki#tree_map.
|
||||||
|
|||||||
+9
-3
@@ -135,7 +135,9 @@ module Gollum
|
|||||||
|
|
||||||
parents = pcommit ? [pcommit] : []
|
parents = pcommit ? [pcommit] : []
|
||||||
actor = Grit::Actor.new(commit[:name], commit[:email])
|
actor = Grit::Actor.new(commit[:name], commit[:email])
|
||||||
index.commit(commit[:message], parents, actor)
|
sha = index.commit(commit[:message], parents, actor)
|
||||||
|
@ref_map.clear
|
||||||
|
sha
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Update an existing page with new content. The location of the
|
# Public: Update an existing page with new content. The location of the
|
||||||
@@ -172,7 +174,9 @@ module Gollum
|
|||||||
end
|
end
|
||||||
|
|
||||||
actor = Grit::Actor.new(commit[:name], commit[:email])
|
actor = Grit::Actor.new(commit[:name], commit[:email])
|
||||||
index.commit(commit[:message], [pcommit], actor)
|
sha = index.commit(commit[:message], [pcommit], actor)
|
||||||
|
@ref_map.clear
|
||||||
|
sha
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Delete a page.
|
# Public: Delete a page.
|
||||||
@@ -192,7 +196,9 @@ module Gollum
|
|||||||
index.delete(page.path)
|
index.delete(page.path)
|
||||||
|
|
||||||
actor = Grit::Actor.new(commit[:name], commit[:email])
|
actor = Grit::Actor.new(commit[:name], commit[:email])
|
||||||
index.commit(commit[:message], [pcommit], actor)
|
sha = index.commit(commit[:message], [pcommit], actor)
|
||||||
|
@ref_map.clear
|
||||||
|
sha
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Lists all pages for this wiki.
|
# Public: Lists all pages for this wiki.
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ context "Markup" do
|
|||||||
index.add("greek/Bilbo-Baggins.md", content)
|
index.add("greek/Bilbo-Baggins.md", content)
|
||||||
index.commit("Add alpha.jpg")
|
index.commit("Add alpha.jpg")
|
||||||
|
|
||||||
|
@wiki.clear_cache
|
||||||
page = @wiki.page("Bilbo Baggins")
|
page = @wiki.page("Bilbo Baggins")
|
||||||
rendered = Gollum::Markup.new(page).render
|
rendered = Gollum::Markup.new(page).render
|
||||||
assert_equal output, rendered
|
assert_equal output, rendered
|
||||||
|
|||||||
Reference in New Issue
Block a user