mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-11 03:33:07 +00:00
* use svnsync instead of checkout for subversion cache
* create repositories cache directory if it doesn't exists (default to RAILS_ROOT/tmp/scm) git-svn-id: http://redmine.rubyforge.org/svn/branches/nbc@1906 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
89b8bf3dc5
commit
fdbe52a2f7
@ -142,8 +142,11 @@ class Repository < ActiveRecord::Base
|
|||||||
private
|
private
|
||||||
|
|
||||||
def repositories_cache_directory
|
def repositories_cache_directory
|
||||||
dir = Setting.repositories_cache_directory.gsub(/^([^#{File::SEPARATOR}].*)/, RAILS_ROOT + '/\1')
|
unless @cache_directory
|
||||||
return dir if File.directory?(dir)
|
@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
|
end
|
||||||
|
|
||||||
def before_save
|
def before_save
|
||||||
|
|||||||
@ -26,6 +26,11 @@ module Redmine
|
|||||||
# SVN executable name
|
# SVN executable name
|
||||||
SVN_BIN = "svn"
|
SVN_BIN = "svn"
|
||||||
|
|
||||||
|
def initialize(url, root_url=nil, login=nil, password=nil, cache_path=nil)
|
||||||
|
super(url, root_url, login, password, cache_path)
|
||||||
|
@url = 'file://' + @url unless cache_path.blank?
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def client_version
|
def client_version
|
||||||
@@client_version ||= (svn_binary_version || [])
|
@@client_version ||= (svn_binary_version || [])
|
||||||
@ -216,14 +221,28 @@ module Redmine
|
|||||||
|
|
||||||
def create_cache
|
def create_cache
|
||||||
return if @orig_url.blank?
|
return if @orig_url.blank?
|
||||||
cmd = "#{SVN_BIN} checkout --non-interactive #{@orig_url} #{@root_url}"
|
cmd = "svnadmin create #{@root_url}"
|
||||||
shellout(cmd) { |io| io.read }
|
shellout(cmd) { |io| io.read }
|
||||||
|
|
||||||
|
File.open("#{@root_url}/hooks/pre-revprop-change", "w") do |io|
|
||||||
|
io.puts <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
USER="$3"
|
||||||
|
if [ "$USER" = "svnsync" ]; then exit 0; fi
|
||||||
|
echo "Only the svnsync user can change revprops" >&2
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
File.chmod 0500, "#{root_url}/hooks/pre-revprop-change"
|
||||||
|
cmd = "svnsync init --username svnsync #{@url} #{@orig_url}"
|
||||||
|
shellout(cmd) { |io| io.read }
|
||||||
|
synchronize
|
||||||
end
|
end
|
||||||
|
|
||||||
def synchronize
|
def synchronize
|
||||||
return if @orig_url.blank?
|
return if @orig_url.blank?
|
||||||
cmd = "#{SVN_BIN} update --non-interactive"
|
cmd = "svnsync sync #{@url}"
|
||||||
Dir.chdir(@root_url) { shellout(cmd) { |io| io.read } }
|
shellout(cmd) { |io| io.read }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user