зеркало из https://github.com/github/grit.git
add enable/disable daemon serve
This commit is contained in:
Родитель
8f24479836
Коммит
02879cf62c
|
@ -1,6 +1,7 @@
|
|||
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
||||
|
||||
# core
|
||||
require 'fileutils'
|
||||
|
||||
# stdlib
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
module Grit
|
||||
|
||||
class Repo
|
||||
DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
|
||||
|
||||
# The path of the git repo as a String
|
||||
attr_accessor :path
|
||||
attr_reader :bare
|
||||
|
@ -199,6 +201,30 @@ module Grit
|
|||
self.git.archive(options, treeish, "| gzip")
|
||||
end
|
||||
|
||||
# Enable git-daemon serving of this repository by writing the
|
||||
# git-daemon-export-ok file to its git directory
|
||||
#
|
||||
# Returns nothing
|
||||
def enable_daemon_serve
|
||||
if @bare
|
||||
FileUtils.touch(File.join(self.path, DAEMON_EXPORT_FILE))
|
||||
else
|
||||
FileUtils.touch(File.join(self.path, '.git', DAEMON_EXPORT_FILE))
|
||||
end
|
||||
end
|
||||
|
||||
# Disable git-daemon serving of this repository by ensuring there is no
|
||||
# git-daemon-export-ok file in its git directory
|
||||
#
|
||||
# Returns nothing
|
||||
def disable_daemon_serve
|
||||
if @bare
|
||||
FileUtils.rm_f(File.join(self.path, DAEMON_EXPORT_FILE))
|
||||
else
|
||||
FileUtils.rm_f(File.join(self.path, '.git', DAEMON_EXPORT_FILE))
|
||||
end
|
||||
end
|
||||
|
||||
# Pretty object inspection
|
||||
def inspect
|
||||
%Q{#<Grit::Repo "#{@path}">}
|
||||
|
|
|
@ -174,6 +174,20 @@ class TestRepo < Test::Unit::TestCase
|
|||
@r.archive_tar_gz
|
||||
end
|
||||
|
||||
# enable_daemon_serve
|
||||
|
||||
def test_enable_daemon_serve
|
||||
FileUtils.expects(:touch).with(File.join(@r.path, '.git', 'git-daemon-export-ok'))
|
||||
@r.enable_daemon_serve
|
||||
end
|
||||
|
||||
# disable_daemon_serve
|
||||
|
||||
def test_disable_daemon_serve
|
||||
FileUtils.expects(:rm_f).with(File.join(@r.path, '.git', 'git-daemon-export-ok'))
|
||||
@r.disable_daemon_serve
|
||||
end
|
||||
|
||||
# inspect
|
||||
|
||||
def test_inspect
|
||||
|
|
Загрузка…
Ссылка в новой задаче