##// END OF EJS Templates
Removed repository creation callback...
Jean-Philippe Lang -
r424:c1a5c5b9f872
parent child
Show More
@@ -1,138 +1,137
1 1 #!/usr/bin/perl
2 2 #
3 3 # redMine is free software; you can redistribute it and/or
4 4 # modify it under the terms of the GNU General Public License
5 5 # as published by the Free Software Foundation; either version 2
6 6 # of the License, or (at your option) any later version.
7 7 #
8 8 # This program is distributed in the hope that it will be useful,
9 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 11 # GNU General Public License for more details.
12 12 #
13 13 # You should have received a copy of the GNU General Public License
14 14 # along with this program; if not, write to the Free Software
15 15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 16
17 17 use strict;
18 18 use SOAP::Lite;
19 19 use Getopt::Long;
20 20 Getopt::Long::Configure ("bundling", "no_auto_abbrev", "no_ignore_case");
21 21 use Pod::Usage;
22 22 use vars qw/$VERSION/;
23 23
24 24 $VERSION = "1.0";
25 25
26 26 my %opts = (verbose => 0);
27 27 GetOptions(\%opts, 'verbose|v+', 'version|V', 'help|h', 'man|m', 'quiet|q', 'svn-dir|s=s', 'redmine-host|r=s') or pod2usage(2);
28 28
29 29 die "$VERSION\n" if $opts{version};
30 30 pod2usage(1) if $opts{help};
31 31 pod2usage( -verbose => 2 ) if $opts{man};
32 32
33 33 my $repos_base = $opts{'svn-dir'};
34 34 my $redmine_host = $opts{'redmine-host'};
35 35
36 36 pod2usage(2) unless $repos_base and $redmine_host;
37 37
38 38 unless (-d $repos_base) {
39 39 Log(text => "$repos_base doesn't exist", exit => 1);
40 40 }
41 41
42 42 Log(level => 1, text => "querying redMine for projects...");
43 43 my $wdsl = "http://$redmine_host/sys/service.wsdl";
44 44 my $service = SOAP::Lite->service($wdsl);
45 45
46 46 my $projects = $service->Projects('');
47 47 my $project_count = @{$projects};
48 48 Log(level => 1, text => "retrieved $project_count projects");
49 49
50 50 foreach my $project (@{$projects}) {
51 51 Log(level => 1, text => "treating project $project->{name}");
52 52 my $repos_name = $project->{identifier};
53 53
54 54 if ($repos_name eq "") {
55 55 Log(text => "\tno identifier for project $project->{name}");
56 56 next;
57 57 }
58 58
59 59 unless ($repos_name =~ /^[a-z0-9\-]+$/) {
60 60 Log(text => "\tinvalid identifier for project $project->{name}");
61 61 next;
62 62 }
63 63
64 64 my $repos_path = "$repos_base/$repos_name";
65 65
66 66 if (-e $repos_path) {
67 67 # check unix right and change them if needed
68 68 my $other_read = (stat($repos_path))[2] & 00007;
69 69 my $right;
70 70
71 71 if ($project->{is_public} and not $other_read) {
72 72 $right = "0775";
73 73 } elsif (not $project->{is_public} and $other_read) {
74 74 $right = "0770";
75 75 } else {
76 76 next;
77 77 }
78 78
79 79 # change mode
80 80 system('chmod', '-R', $right, $repos_path) == 0 or
81 81 warn("\tunable to change mode on $repos_path : $?\n"), next;
82 82
83 83 Log(text => "\tmode change on $repos_path");
84 84
85 85 } else {
86 86 # change umask to suit the repository's privacy
87 87 $project->{is_public} ? umask 0002 : umask 0007;
88 88
89 89 # create the repository
90 90 system('svnadmin', 'create', $repos_path) == 0 or
91 91 warn("\tsystem svnadmin failed unable to create $repos_path\n"), next;
92 92
93 93 # set the group owner
94 94 system('chown', '-R', "root:$repos_name", $repos_path) == 0 or
95 95 warn("\tunable to create $repos_path : $?\n"), next;
96 96
97 97 Log(text => "\trepository $repos_path created");
98 my $call = $service->RepositoryCreated($project->{id}, "svn://host/$repos_name");
99 98 }
100 99 }
101 100
102 101
103 102 sub Log {
104 103 my %args = (level => 0, text => '', @_);
105 104
106 105 my $level = delete $args{level};
107 106 my $text = delete $args{text};
108 107 return unless $level <= $opts{verbose};
109 108 return if $opts{quiet};
110 109 print "$text\n";
111 110
112 111 exit $args{exit}
113 112 if defined $args{exit};
114 113 }
115 114
116 115
117 116 __END__
118 117
119 118 =head1 NAME
120 119
121 120 reposman - manages your svn repositories with redMine
122 121
123 122 =head1 SYNOPSIS
124 123
125 124 reposman [options] arguments
126 125 example: reposman --svn-dir=/var/svn --redmine-host=redmine.mydomain.foo
127 126 reposman -s /var/svn -r redmine.mydomain.foo
128 127
129 128 =head1 ARGUMENTS
130 129
131 130 -s, --svn-dir=DIR use DIR as base directory for svn repositories
132 131 -r, --redmine-host=HOST assume redMine is hosted on HOST
133 132
134 133 =head1 OPTIONS
135 134
136 135 -v verbose
137 136 -V print version and exit
138 137
General Comments 0
You need to be logged in to leave comments. Login now