* reposman can now use an external command with "-c" to create repository of other kind than svn
* WS used by reposman only return projects with repository module enable (so reposman no longer create repository if module is disable) * it doesn't create repository if repository definition already exists in redmine database (unless -f is used) git-svn-id: http://redmine.rubyforge.org/svn/branches/nbc@1793 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+10
-2
@@ -15,10 +15,18 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
class AWSProjectWithRepository < ActionWebService::Struct
|
||||||
|
member :id, :int
|
||||||
|
member :identifier, :string
|
||||||
|
member :name, :string
|
||||||
|
member :is_public, :bool
|
||||||
|
member :repository, Repository
|
||||||
|
end
|
||||||
|
|
||||||
class SysApi < ActionWebService::API::Base
|
class SysApi < ActionWebService::API::Base
|
||||||
api_method :projects,
|
api_method :projects_with_repository_enabled,
|
||||||
:expects => [],
|
:expects => [],
|
||||||
:returns => [[Project]]
|
:returns => [[AWSProjectWithRepository]]
|
||||||
api_method :repository_created,
|
api_method :repository_created,
|
||||||
:expects => [:string, :string],
|
:expects => [:string, :string],
|
||||||
:returns => [:int]
|
:returns => [:int]
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ class SysController < ActionController::Base
|
|||||||
before_invocation :check_enabled
|
before_invocation :check_enabled
|
||||||
|
|
||||||
# Returns the projects list, with their repositories
|
# Returns the projects list, with their repositories
|
||||||
def projects
|
def projects_with_repository_enabled
|
||||||
Project.find(:all, :include => :repository)
|
Project.repository_enabled(:all, :include => :repository)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Registers a repository for the given project identifier
|
# Registers a repository for the given project identifier
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ class Project < ActiveRecord::Base
|
|||||||
|
|
||||||
before_destroy :delete_all_members
|
before_destroy :delete_all_members
|
||||||
|
|
||||||
|
named_scope :repository_enabled, { :include => :enabled_modules, :conditions => ['enabled_modules.name=?', 'repository'] }
|
||||||
|
|
||||||
def identifier=(identifier)
|
def identifier=(identifier)
|
||||||
super unless identifier_frozen?
|
super unless identifier_frozen?
|
||||||
end
|
end
|
||||||
|
|||||||
+23
-2
@@ -37,6 +37,13 @@
|
|||||||
# -u file:///var/svn/ # if the repository is local
|
# -u file:///var/svn/ # if the repository is local
|
||||||
# if this option isn't set, reposman won't register the repository
|
# if this option isn't set, reposman won't register the repository
|
||||||
#
|
#
|
||||||
|
# -c, --command=COMMAND
|
||||||
|
# the default is to create an subversion repository. You can use this command
|
||||||
|
# to create another kind of repository
|
||||||
|
#
|
||||||
|
# -f, --force
|
||||||
|
# force repository creation even if a repository is already declared in redmine.
|
||||||
|
#
|
||||||
# -t, --test
|
# -t, --test
|
||||||
# only show what should be done
|
# only show what should be done
|
||||||
#
|
#
|
||||||
@@ -66,7 +73,9 @@ opts = GetoptLong.new(
|
|||||||
['--redmine-host', '-r', GetoptLong::REQUIRED_ARGUMENT],
|
['--redmine-host', '-r', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
['--owner', '-o', GetoptLong::REQUIRED_ARGUMENT],
|
['--owner', '-o', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
['--url', '-u', GetoptLong::REQUIRED_ARGUMENT],
|
['--url', '-u', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
|
['--command' , '-c', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
['--test', '-t', GetoptLong::NO_ARGUMENT],
|
['--test', '-t', GetoptLong::NO_ARGUMENT],
|
||||||
|
['--force', '-f', GetoptLong::NO_ARGUMENT],
|
||||||
['--verbose', '-v', GetoptLong::NO_ARGUMENT],
|
['--verbose', '-v', GetoptLong::NO_ARGUMENT],
|
||||||
['--version', '-V', GetoptLong::NO_ARGUMENT],
|
['--version', '-V', GetoptLong::NO_ARGUMENT],
|
||||||
['--help' , '-h', GetoptLong::NO_ARGUMENT],
|
['--help' , '-h', GetoptLong::NO_ARGUMENT],
|
||||||
@@ -81,6 +90,8 @@ $svn_owner = 'root'
|
|||||||
$use_groupid = true
|
$use_groupid = true
|
||||||
$svn_url = false
|
$svn_url = false
|
||||||
$test = false
|
$test = false
|
||||||
|
$command = "svnadmin create"
|
||||||
|
$force = false
|
||||||
|
|
||||||
def log(text,level=0, exit=false)
|
def log(text,level=0, exit=false)
|
||||||
return if $quiet or level > $verbose
|
return if $quiet or level > $verbose
|
||||||
@@ -95,8 +106,10 @@ begin
|
|||||||
when '--redmine-host'; $redmine_host = arg.dup
|
when '--redmine-host'; $redmine_host = arg.dup
|
||||||
when '--owner'; $svn_owner = arg.dup; $use_groupid = false;
|
when '--owner'; $svn_owner = arg.dup; $use_groupid = false;
|
||||||
when '--url'; $svn_url = arg.dup
|
when '--url'; $svn_url = arg.dup
|
||||||
|
when '--command'; $command = arg.dup
|
||||||
when '--verbose'; $verbose += 1
|
when '--verbose'; $verbose += 1
|
||||||
when '--test'; $test = true
|
when '--test'; $test = true
|
||||||
|
when '--force'; $force = true
|
||||||
when '--version'; puts Version; exit
|
when '--version'; puts Version; exit
|
||||||
when '--help'; RDoc::usage
|
when '--help'; RDoc::usage
|
||||||
when '--quiet'; $quiet = true
|
when '--quiet'; $quiet = true
|
||||||
@@ -133,7 +146,7 @@ rescue => e
|
|||||||
log("Unable to connect to #{wsdl_url} : #{e}", 0, true)
|
log("Unable to connect to #{wsdl_url} : #{e}", 0, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
projects = soap.Projects
|
projects = soap.ProjectsWithRepositoryEnabled
|
||||||
|
|
||||||
if projects.nil?
|
if projects.nil?
|
||||||
log('no project found, perhaps you forgot to "Enable WS for repository management"', 0, true)
|
log('no project found, perhaps you forgot to "Enable WS for repository management"', 0, true)
|
||||||
@@ -201,6 +214,13 @@ projects.each do |project|
|
|||||||
log("\tmode change on #{repos_path}");
|
log("\tmode change on #{repos_path}");
|
||||||
|
|
||||||
else
|
else
|
||||||
|
# if repository is already declared in redmine, we don't create
|
||||||
|
# unless user use -f with reposman
|
||||||
|
if $force == false and not project.repository.nil?
|
||||||
|
log("\trepository for project #{project.identifier} already exists in Redmine", 1)
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
project.is_public ? File.umask(0002) : File.umask(0007)
|
project.is_public ? File.umask(0002) : File.umask(0007)
|
||||||
|
|
||||||
if $test
|
if $test
|
||||||
@@ -211,7 +231,8 @@ projects.each do |project|
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
set_owner_and_rights(project, repos_path) do
|
set_owner_and_rights(project, repos_path) do
|
||||||
raise "svnadmin create #{repos_path} failed" unless system("svnadmin", "create", repos_path)
|
command = "#{$command} #{repos_path}"
|
||||||
|
raise "#{command} failed" unless system( command )
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
log("\tunable to create #{repos_path} : #{e}\n")
|
log("\tunable to create #{repos_path} : #{e}\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user