add basic GitAccess class

This commit is contained in:
rick
2010-10-08 13:36:18 -07:00
parent c0f8c897e7
commit 62c4b795be
3 changed files with 24 additions and 3 deletions
+1
View File
@@ -11,6 +11,7 @@ require 'sanitize'
require 'gollum/ruby1.8'
# internal
require 'gollum/git_access'
require 'gollum/pagination'
require 'gollum/blob_entry'
require 'gollum/wiki'
+19
View File
@@ -0,0 +1,19 @@
module Gollum
class GitAccess
attr_reader :path
attr_reader :repo
attr_reader :ref_map
attr_reader :tree_map
def initialize(path)
@path = path
@repo = Grit::Repo.new(path)
@ref_map = {}
@tree_map = {}
end
def exist?
@repo.git.exist?
end
end
end
+4 -3
View File
@@ -59,7 +59,8 @@ module Gollum
# Returns a fresh Gollum::Repo.
def initialize(path, options = {})
@path = path
@repo = Grit::Repo.new(path)
@access = options[:access] || GitAccess.new(path)
@repo = @access.repo
@base_path = options[:base_path] || "/"
@page_class = options[:page_class] || self.class.page_class
@file_class = options[:file_class] || self.class.file_class
@@ -70,7 +71,7 @@ module Gollum
#
# Returns true if the repo exists, and false if it does not.
def exist?
@repo.git.exist?
@access.exist?
end
# Public: Get the formatted page for a given page name.
@@ -520,7 +521,7 @@ module Gollum
data, name = line.split("\t")
mode, type, sha = data.split(' ')
name = decode_git_path(name)
BlobEntry.new sha, name
BlobEntry.new(sha, name)
end
# Decode octal sequences (\NNN) in tree path names.