From 62c4b795be45bc6c7e3e47deec69af44d8015973 Mon Sep 17 00:00:00 2001 From: rick Date: Fri, 8 Oct 2010 13:36:18 -0700 Subject: [PATCH] add basic GitAccess class --- lib/gollum.rb | 1 + lib/gollum/git_access.rb | 19 +++++++++++++++++++ lib/gollum/wiki.rb | 7 ++++--- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 lib/gollum/git_access.rb diff --git a/lib/gollum.rb b/lib/gollum.rb index 36bcab92..fd2a4ab1 100644 --- a/lib/gollum.rb +++ b/lib/gollum.rb @@ -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' diff --git a/lib/gollum/git_access.rb b/lib/gollum/git_access.rb new file mode 100644 index 00000000..7f9c299d --- /dev/null +++ b/lib/gollum/git_access.rb @@ -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 \ No newline at end of file diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 172aa9aa..d7f68556 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -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.