diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 11645eff..8e0b7498 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -246,7 +246,11 @@ module Gollum # Returns an Array with Objects of page name and count of matches def search(query) # See: http://github.com/Sirupsen/gollum/commit/f0a6f52bdaf6bee8253ca33bb3fceaeb27bfb87e - search_output = @repo.git.grep({:c => query}, 'master') + if @page_file_dir + search_output = @repo.git.grep({:c => query}, 'master', '--', @page_file_dir) + else + search_output = @repo.git.grep({:c => query}, 'master') + end search_output.split("\n").collect do |line| result = line.split(':') diff --git a/test/test_wiki.rb b/test/test_wiki.rb index cf3e6aa7..6df4e170 100644 --- a/test/test_wiki.rb +++ b/test/test_wiki.rb @@ -314,6 +314,12 @@ context "page_file_dir option" do assert !@wiki.page("bar") end + test "search results should be restricted in page filer dir" do + results = @wiki.search("Hello") + assert_equal 1, results.size + assert_equal "foo", results[0][:name] + end + teardown do FileUtils.rm_r(@path) end