Sha256: 59e41bc49bb9f9200674bfb619bec52b9adae15840ab22cbbc14603f2a44561d

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 KB

Contents

#!/usr/bin/env ruby
# Copyright (c) 2009, Keith Salisbury (www.globalkeith.com)
# All rights reserved.
# All the svn stuff should go in here...

require 'fileutils'

module Subtrac
  class Svn

    def initialize
      File.create_if_missing(Config.svn_dir)
    end

    # creates a new svn repository for the project
    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} already exists in the #{client} 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}`

      # copy template svn project to a temp folder, then svn import it into the repo
      say("Create temporary project directory and copy template files...")
      svn_template_dir = File.join(project.template,"svn")
      project_temp_dir = File.join(Config.temp_dir,project.path)
      FileUtils.cp_r(svn_template_dir,project_temp_dir)
      
      # import into svn
      say("Importing temporary project into the new subversion repository...")
      `svn import #{project_temp_dir} file:///#{project.svn_dir} --message "initial import"`

      # delete the temporary directory
      FileUtils.rm_r(project_temp_dir, :force => true)

      # 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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ktec-subtrac-0.1.44 lib/subtrac/svn.rb
ktec-subtrac-0.1.45 lib/subtrac/svn.rb
ktec-subtrac-0.1.46 lib/subtrac/svn.rb