Class: Subtrac::Svn

Inherits:
Object
  • Object
show all
Defined in:
lib/subtrac/svn.rb

Instance Method Summary collapse

Constructor Details

#initializeSvn

Returns a new instance of Svn.



11
12
13
# File 'lib/subtrac/svn.rb', line 11

def initialize
  File.create_if_missing(Config.svn_dir)
end

Instance Method Details

#create_project(project) ⇒ Object

creates a new svn repository for the project



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/subtrac/svn.rb', line 16

def create_project(project)
  
  # get the client for this project
  client = project.client

  # create the client folder
  File.create_if_missing(File.join(Config.svn_dir,client.path))

  # create the project folder
  project.svn_dir = File.join(Config.svn_dir,client.path,project.path)
  
  # TODO: Need to handle this exception...
  if (File.directory? project.svn_dir) then
    raise StandardError, "A project called #{project.display_name} already exists in the #{client.display_name} repository. Please delete it or choose an alternate project name and run this script again."
  end
  
  # create a new subversion repository
  say("Creating a new subversion repository...")
  `svnadmin create #{project.svn_dir}`

  # import into svn
  say("Importing temporary project into the new subversion repository...")
  `svn import #{project.template}/svn file:///#{project.svn_dir} --message "initial import"`

  # this should fix the 'can't open activity db error'
  `sudo chmod 770 #{project.svn_dir}`
  `sudo chmod 755 #{project.svn_dir}/dav/activities`
  `sudo chown www-data:www-data #{project.svn_dir}/dav/activities`

end