Add Wiki#files for list of non-page files.
This commit is contained in:
@@ -446,6 +446,15 @@ module Gollum
|
||||
tree_list(treeish || @ref)
|
||||
end
|
||||
|
||||
# Public: Lists all non-page files for this wiki.
|
||||
#
|
||||
# treeish - The String commit ID or ref to find (default: @ref)
|
||||
#
|
||||
# Returns an Array of Gollum::File instances.
|
||||
def files(treeish = nil)
|
||||
file_list(treeish || @ref)
|
||||
end
|
||||
|
||||
# Public: Returns the number of pages accessible from a commit
|
||||
#
|
||||
# ref - A String ref that is either a commit SHA or references one.
|
||||
@@ -595,6 +604,24 @@ module Gollum
|
||||
end
|
||||
end
|
||||
|
||||
# Fill an array with a list of files.
|
||||
#
|
||||
# ref - A String ref that is either a commit SHA or references one.
|
||||
#
|
||||
# Returns a flat Array of Gollum::File instances.
|
||||
def file_list(ref)
|
||||
if sha = @access.ref_to_sha(ref)
|
||||
commit = @access.commit(sha)
|
||||
tree_map_for(sha).inject([]) do |list, entry|
|
||||
next list if entry.name.start_with?('_')
|
||||
next list if @page_class.valid_page_name?(entry.name)
|
||||
list << entry.file(self, commit)
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
# Creates a reverse diff for the given SHAs on the given Gollum::Page.
|
||||
#
|
||||
# page - The Gollum::Page to scope the patch to, or a String Path.
|
||||
|
||||
Reference in New Issue
Block a user