##// END OF EJS Templates
Adds --scm option support to reposman. It can be used to register non subversion repositories in Redmine....
Jean-Philippe Lang -
r1807:0b74888fb8c6
parent child
Show More
@@ -6,65 +6,49
6 #
6 #
7 # == Usage
7 # == Usage
8 #
8 #
9 # reposman [ -h | --help ] [ -v | --verbose ] [ -V | --version ] [ -q | --quiet ] -s /var/svn -r redmine.host.org
9 # reposman [OPTIONS...] -s [DIR] -r [HOST]
10 # example: reposman --svn-dir=/var/svn --redmine-host=redmine.mydomain.foo
11 # reposman -s /var/svn -r redmine.mydomain.foo
12 #
10 #
13 # == Arguments (mandatory)
11 # Examples:
12 # reposman --svn-dir=/var/svn --redmine-host=redmine.example.net
13 # reposman -s /var/svn -r redmine.example.net -u http://svn.example.net
14 #
14 #
15 # -s, --svn-dir=DIR
15 # == Arguments (mandatory)
16 # use DIR as base directory for svn repositories
17 #
16 #
18 # -r, --redmine-host=HOST
17 # -s, --svn-dir=DIR use DIR as base directory for svn repositories
19 # assume Redmine is hosted on HOST.
18 # -r, --redmine-host=HOST assume Redmine is hosted on HOST. Examples:
20 # you can use :
19 # -r redmine.example.net
21 # * -r redmine.mydomain.foo (will add http://)
20 # -r http://redmine.example.net
22 # * -r http://redmine.mydomain.foo
21 # -r https://example.net/redmine
23 # * -r https://mydomain.foo/redmine
24 #
22 #
25 # == Options
23 # == Options
26 #
24 #
27 # -o, --owner=OWNER
25 # -o, --owner=OWNER owner of the repository. using the rails login
28 # owner of the repository. using the rails login allow user to browse
26 # allow user to browse the repository within
29 # the repository in Redmine even for private project
27 # Redmine even for private project
30 #
28 # -u, --url=URL the base url Redmine will use to access your
31 # -u, --url=URL
29 # repositories. This option is used to automatically
32 # the base url Redmine will use to access your repositories. This
30 # register the repositories in Redmine. The project
33 # will be used to register the repository in Redmine so that user
31 # identifier will be appended to this url. Examples:
34 # doesn't need to do anything. reposman will add the identifier to this url :
32 # -u https://example.net/svn
35 #
33 # -u file:///var/svn/
36 # -u https://my.svn.server/my/reposity/root # if the repository can be access by http
34 # if this option isn't set, reposman won't register
37 # -u file:///var/svn/ # if the repository is local
35 # the repositories in Redmine
38 # if this option isn't set, reposman won't register the repository
36 # -c, --command=COMMAND use this command instead of "svnadmin create" to
39 #
37 # create a repository. This option can be used to
40 # --scm
38 # create non-subversion repositories
41 # SCM vendor used to register the repository in Redmine (default: Subversion)
39 # --scm SCM vendor used to register the repository in
42 # Can be one of the other supported SCM: Bazaar, Cvs, Darcs, Filesystem, Git, Mercurial (case sensitive).
40 # Redmine (default: Subversion). Can be one of the
43 # This option should be used when using --command to create another kind
41 # other supported SCM: Bazaar, Darcs, Filesystem,
44 # of repository.
42 # Git, Mercurial (case sensitive).
45 #
43 # This option should be used when both options --url
46 # -c, --command=COMMAND
44 # and --command are used.
47 # the default is to create an subversion repository. You can use this command
45 # -f, --force force repository creation even if the project
48 # to create another kind of repository
46 # repository is already declared in Redmine
49 #
47 # -t, --test only show what should be done
50 # -f, --force
48 # -h, --help show help and exit
51 # force repository creation even if a repository is already declared in redmine.
49 # -v, --verbose verbose
52 #
50 # -V, --version print version and exit
53 # -t, --test
51 # -q, --quiet no log
54 # only show what should be done
55 #
56 # -h, --help:
57 # show help and exit
58 #
59 # -v, --verbose
60 # verbose
61 #
62 # -V, --version
63 # print version and exit
64 #
65 # -q, --quiet
66 # no log
67 #
68
52
69 require 'getoptlong'
53 require 'getoptlong'
70 require 'rdoc/usage'
54 require 'rdoc/usage'
@@ -72,15 +56,16 require 'soap/wsdlDriver'
72 require 'find'
56 require 'find'
73 require 'etc'
57 require 'etc'
74
58
75 Version = "1.0"
59 Version = "1.1"
60 SUPPORTED_SCM = %w( Subversion Darcs Mercurial Bazaar Git Filesystem )
76
61
77 opts = GetoptLong.new(
62 opts = GetoptLong.new(
78 ['--svn-dir', '-s', GetoptLong::REQUIRED_ARGUMENT],
63 ['--svn-dir', '-s', GetoptLong::REQUIRED_ARGUMENT],
79 ['--redmine-host', '-r', GetoptLong::REQUIRED_ARGUMENT],
64 ['--redmine-host', '-r', GetoptLong::REQUIRED_ARGUMENT],
80 ['--owner', '-o', GetoptLong::REQUIRED_ARGUMENT],
65 ['--owner', '-o', GetoptLong::REQUIRED_ARGUMENT],
81 ['--url', '-u', GetoptLong::REQUIRED_ARGUMENT],
66 ['--url', '-u', GetoptLong::REQUIRED_ARGUMENT],
82 ['--scm', GetoptLong::REQUIRED_ARGUMENT],
83 ['--command' , '-c', GetoptLong::REQUIRED_ARGUMENT],
67 ['--command' , '-c', GetoptLong::REQUIRED_ARGUMENT],
68 ['--scm', GetoptLong::REQUIRED_ARGUMENT],
84 ['--test', '-t', GetoptLong::NO_ARGUMENT],
69 ['--test', '-t', GetoptLong::NO_ARGUMENT],
85 ['--force', '-f', GetoptLong::NO_ARGUMENT],
70 ['--force', '-f', GetoptLong::NO_ARGUMENT],
86 ['--verbose', '-v', GetoptLong::NO_ARGUMENT],
71 ['--verbose', '-v', GetoptLong::NO_ARGUMENT],
@@ -114,7 +99,7 begin
114 when '--redmine-host'; $redmine_host = arg.dup
99 when '--redmine-host'; $redmine_host = arg.dup
115 when '--owner'; $svn_owner = arg.dup; $use_groupid = false;
100 when '--owner'; $svn_owner = arg.dup; $use_groupid = false;
116 when '--url'; $svn_url = arg.dup
101 when '--url'; $svn_url = arg.dup
117 when '--scm'; $scm = arg.dup
102 when '--scm'; $scm = arg.dup; log("Invalid SCM: #{$scm}", 0, true) unless SUPPORTED_SCM.include?($scm)
118 when '--command'; $command = arg.dup
103 when '--command'; $command = arg.dup
119 when '--verbose'; $verbose += 1
104 when '--verbose'; $verbose += 1
120 when '--test'; $test = true
105 when '--test'; $test = true
@@ -132,6 +117,12 if $test
132 log("running in test mode")
117 log("running in test mode")
133 end
118 end
134
119
120 # Make sure command is overridden if SCM vendor is not Subversion
121 if $scm != 'Subversion' && $command == 'svnadmin create'
122 log("Please use --command option to specify how to create a #{$scm} repository.", 0, true)
123 end
124
125
135 $svn_url += "/" if $svn_url and not $svn_url.match(/\/$/)
126 $svn_url += "/" if $svn_url and not $svn_url.match(/\/$/)
136
127
137 if ($redmine_host.empty? or $repos_base.empty?)
128 if ($redmine_host.empty? or $repos_base.empty?)
General Comments 0
You need to be logged in to leave comments. Login now