Mercurial > hg > soundsoftware-site
comparison extra/svn/.svn/text-base/reposman.rb.svn-base @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 94944d00e43c |
children |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
5 # reposman: manages your repositories with Redmine | 5 # reposman: manages your repositories with Redmine |
6 # | 6 # |
7 # == Usage | 7 # == Usage |
8 # | 8 # |
9 # reposman [OPTIONS...] -s [DIR] -r [HOST] | 9 # reposman [OPTIONS...] -s [DIR] -r [HOST] |
10 # | 10 # |
11 # Examples: | 11 # Examples: |
12 # reposman --svn-dir=/var/svn --redmine-host=redmine.example.net --scm subversion | 12 # reposman --svn-dir=/var/svn --redmine-host=redmine.example.net --scm subversion |
13 # reposman -s /var/git -r redmine.example.net -u http://svn.example.net --scm git | 13 # reposman -s /var/git -r redmine.example.net -u http://svn.example.net --scm git |
14 # | 14 # |
15 # == Arguments (mandatory) | 15 # == Arguments (mandatory) |
55 # -v, --verbose verbose | 55 # -v, --verbose verbose |
56 # -V, --version print version and exit | 56 # -V, --version print version and exit |
57 # -q, --quiet no log | 57 # -q, --quiet no log |
58 # | 58 # |
59 # == References | 59 # == References |
60 # | 60 # |
61 # You can find more information on the redmine's wiki : http://www.redmine.org/wiki/redmine/HowTos | 61 # You can find more information on the redmine's wiki : http://www.redmine.org/wiki/redmine/HowTos |
62 | 62 |
63 | 63 |
64 require 'getoptlong' | 64 require 'getoptlong' |
65 require 'rdoc/usage' | 65 require 'rdoc/usage' |
203 end | 203 end |
204 | 204 |
205 log("retrieved #{projects.size} projects", :level => 1) | 205 log("retrieved #{projects.size} projects", :level => 1) |
206 | 206 |
207 def set_owner_and_rights(project, repos_path, &block) | 207 def set_owner_and_rights(project, repos_path, &block) |
208 if RUBY_PLATFORM =~ /mswin/ | 208 if mswin? |
209 yield if block_given? | 209 yield if block_given? |
210 else | 210 else |
211 uid, gid = Etc.getpwnam($svn_owner).uid, ($use_groupid ? Etc.getgrnam(project.identifier).gid : Etc.getgrnam($svn_group).gid) | 211 uid, gid = Etc.getpwnam($svn_owner).uid, ($use_groupid ? Etc.getgrnam(project.identifier).gid : Etc.getgrnam($svn_group).gid) |
212 right = project.is_public ? 0775 : 0770 | 212 right = project.is_public ? 0775 : 0770 |
213 yield if block_given? | 213 yield if block_given? |
223 end | 223 end |
224 | 224 |
225 def owner_name(file) | 225 def owner_name(file) |
226 mswin? ? | 226 mswin? ? |
227 $svn_owner : | 227 $svn_owner : |
228 Etc.getpwuid( File.stat(file).uid ).name | 228 Etc.getpwuid( File.stat(file).uid ).name |
229 end | 229 end |
230 | 230 |
231 def mswin? | 231 def mswin? |
232 (RUBY_PLATFORM =~ /(:?mswin|mingw)/) || (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i) | 232 (RUBY_PLATFORM =~ /(:?mswin|mingw)/) || (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i) |
233 end | 233 end |
234 | 234 |
235 projects.each do |project| | 235 projects.each do |project| |
244 end | 244 end |
245 | 245 |
246 repos_path = File.join($repos_base, project.identifier).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR) | 246 repos_path = File.join($repos_base, project.identifier).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR) |
247 | 247 |
248 if File.directory?(repos_path) | 248 if File.directory?(repos_path) |
249 | |
250 # we must verify that repository has the good owner and the good | 249 # we must verify that repository has the good owner and the good |
251 # rights before leaving | 250 # rights before leaving |
252 other_read = other_read_right?(repos_path) | 251 other_read = other_read_right?(repos_path) |
253 owner = owner_name(repos_path) | 252 owner = owner_name(repos_path) |
254 next if project.is_public == other_read and owner == $svn_owner | 253 next if project.is_public == other_read and owner == $svn_owner |
302 log("\trepository #{repos_path} registered in Redmine with url #{$svn_url}#{project.identifier}"); | 301 log("\trepository #{repos_path} registered in Redmine with url #{$svn_url}#{project.identifier}"); |
303 rescue => e | 302 rescue => e |
304 log("\trepository #{repos_path} not registered in Redmine: #{e.message}"); | 303 log("\trepository #{repos_path} not registered in Redmine: #{e.message}"); |
305 end | 304 end |
306 end | 305 end |
307 | |
308 log("\trepository #{repos_path} created"); | 306 log("\trepository #{repos_path} created"); |
309 end | 307 end |
310 | 308 end |
311 end | |
312 |