delete_page

This commit is contained in:
Tom Preston-Werner
2010-04-20 18:19:54 -07:00
parent 6bb9d3408c
commit 63099ec5c0
2 changed files with 60 additions and 0 deletions
+27
View File
@@ -77,6 +77,33 @@ module Gollum
index.commit(commit[:message], [pcommit], actor)
end
# Public: Delete a page.
#
# page - The Gollum::Page to delete.
# commit - The commit Hash details:
# :message - The String commit message.
# :author - The String author full name.
# :email - The String email address.
#
# Returns the String SHA1 of the newly written version.
def delete_page(page, commit)
pcommit = @repo.commit('master')
map = tree_map(pcommit.tree)
parts = page.path.split('/')
name = parts.pop
container = nil
parts.each do |part|
container = map[part]
end
(container || map).delete(name)
index = tree_map_to_index(map)
actor = Grit::Actor.new(commit[:name], commit[:email])
index.commit(commit[:message], [pcommit], actor)
end
#########################################################################
#
# Internal Methods