private
def repositories_cache_directory
- dir = Setting.repositories_cache_directory.gsub(/^([^#{File::SEPARATOR}].*)/, RAILS_ROOT + '/\1')
- return dir if File.directory?(dir)
+ unless @cache_directory
+ @cache_directory = Setting.repositories_cache_directory.gsub(/^([^#{File::SEPARATOR}].*)/, RAILS_ROOT + '/\1/')
+ Dir.mkdir(@cache_directory, File.umask(0077)) unless File.directory?(@cache_directory)
+ end
+ @cache_directory
end
def before_save
# SVN executable name\r
SVN_BIN = "svn"\r
\r
+ def initialize(url, root_url=nil, login=nil, password=nil, cache_path=nil)\r
+ super(url, root_url, login, password, cache_path)\r
+ @url = 'file://' + @url unless cache_path.blank?\r
+ end\r
+\r
class << self\r
def client_version\r
@@client_version ||= (svn_binary_version || [])\r
\r
def create_cache\r
return if @orig_url.blank?\r
- cmd = "#{SVN_BIN} checkout --non-interactive #{@orig_url} #{@root_url}"\r
+ cmd = "svnadmin create #{@root_url}"\r
+ shellout(cmd) { |io| io.read }\r
+\r
+ File.open("#{@root_url}/hooks/pre-revprop-change", "w") do |io|\r
+ io.puts <<'EOF'\r
+#!/bin/sh\r
+USER="$3"\r
+if [ "$USER" = "svnsync" ]; then exit 0; fi\r
+echo "Only the svnsync user can change revprops" >&2\r
+exit 1\r
+EOF\r
+end\r
+ File.chmod 0500, "#{root_url}/hooks/pre-revprop-change"\r
+ cmd = "svnsync init --username svnsync #{@url} #{@orig_url}"\r
shellout(cmd) { |io| io.read }\r
+ synchronize\r
end\r
\r
def synchronize\r
return if @orig_url.blank?\r
- cmd = "#{SVN_BIN} update --non-interactive"\r
- Dir.chdir(@root_url) { shellout(cmd) { |io| io.read } }\r
+ cmd = "svnsync sync #{@url}"\r
+ shellout(cmd) { |io| io.read }\r
end\r
\r
private\r