From f81634728d02bf8fb547ede4c62279551eb0bddb Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Thu, 8 Aug 2013 21:36:30 +0200 Subject: [PATCH] Replaced grit calls to new calls in gollum-lib 1.06 (set_git_timeout and set_git_max_filsize). Removed grit dependency from tests, using cp of empty.git instead. Replaced Grit exceptions with equivalents in the Gollum module. --- bin/gollum | 4 ++-- gollum.gemspec | 2 +- lib/gollum.rb | 1 - lib/gollum/app.rb | 4 ++-- templates/helper_wiki.rb | 5 +++-- test/test_page_view.rb | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/gollum b/bin/gollum index 5271c1a3..f578658e 100755 --- a/bin/gollum +++ b/bin/gollum @@ -146,7 +146,7 @@ if options['irb'] begin require 'gollum-lib' wiki = Gollum::Wiki.new(gollum_path, wiki_options) - if !wiki.exist? then raise Grit::InvalidGitRepositoryError end + if !wiki.exist? then raise Gollum::InvalidGitRepositoryError end puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}." puts puts %( page = wiki.page('page-name')) @@ -160,7 +160,7 @@ if options['irb'] puts puts "Check out the Gollum README for more." IRB.start_session(binding) - rescue Grit::InvalidGitRepositoryError, Grit::NoSuchPathError + rescue Gollum::InvalidGitRepositoryError, Gollum::NoSuchPathError puts "Invalid Gollum wiki at #{File.expand_path(gollum_path).inspect}" exit 0 end diff --git a/gollum.gemspec b/gollum.gemspec index 226471e7..eb338b94 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |s| s.rdoc_options = ["--charset=UTF-8"] s.extra_rdoc_files = %w[README.md LICENSE] - s.add_dependency 'gollum-lib', '~> 1.0.4' + s.add_dependency 'gollum-lib', '~> 1.0.6' s.add_dependency 'sinatra', '~> 1.4.2' s.add_dependency 'mustache', ['>= 0.99.4', '< 1.0.0'] s.add_dependency 'useragent', '~> 0.6.0' diff --git a/lib/gollum.rb b/lib/gollum.rb index fe0e7761..351f9b78 100644 --- a/lib/gollum.rb +++ b/lib/gollum.rb @@ -5,7 +5,6 @@ require 'digest/sha1' require 'ostruct' # external -require 'grit' require 'github/markup' require 'sanitize' diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 2ca6381b..0f732477 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -14,8 +14,8 @@ require 'gollum/views/has_page' require File.expand_path '../helpers', __FILE__ #required to upload bigger binary files -Grit::Git.git_timeout = 120 # timeout in secs -Grit::Git.git_max_size = 190 * 10**6 # size in bytes (10^6=1 MB) +Gollum::set_git_timeout(120) +Gollum::set_git_max_filesize(190 * 10**6) # Fix to_url class String diff --git a/templates/helper_wiki.rb b/templates/helper_wiki.rb index 1a6c468c..e43db0d4 100644 --- a/templates/helper_wiki.rb +++ b/templates/helper_wiki.rb @@ -1,7 +1,8 @@ class WikiFactory def self.create p - path = testpath "examples/test.git" - Grit::Repo.init_bare(@path) + examples = testpath "examples" + path = File.join(examples, "test.git") + FileUtils.cp_r File.join(examples, "empty.git"), path, :remove_destination => true Gollum::Wiki.default_options = {:universal_toc => false} cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) } Gollum::Wiki.new(@path), @path, cleanup diff --git a/test/test_page_view.rb b/test/test_page_view.rb index 8b1c266a..d2376686 100644 --- a/test/test_page_view.rb +++ b/test/test_page_view.rb @@ -4,9 +4,9 @@ require File.expand_path '../../lib/gollum/views/page', __FILE__ context "Precious::Views::Page" do setup do - @path = testpath("examples/test.git") - FileUtils.rm_rf(@path) - @repo = Grit::Repo.init_bare(@path) + examples = testpath "examples" + @path = File.join(examples, "test.git") + FileUtils.cp_r File.join(examples, "empty.git"), @path, :remove_destination => true @wiki = Gollum::Wiki.new(@path) end @@ -43,4 +43,4 @@ context "Precious::Views::Page" do actual = @view.title assert_equal 'H1', title end -end \ No newline at end of file +end