3 # migrate gitosis.conf to gitolite.conf format
5 # Based on gl-conf-convert by: Sitaram Chamarty
6 # Rewritten by: Behan Webster <behanw@websterwood.com>
12 if (not @ARGV and -t
or @ARGV and $ARGV[0] eq '-h') {
13 print "Usage:\n gl-conf-convert < gitosis.conf > gitolite.conf\n(please see the documentation for details)\n";
26 if (/^repositories *=/ or /^map /) {
27 print STDERR
"not supported: $_";
33 # normalise whitespace to help later regexes
40 if (/^\s*$/ and @comments > 1) {
41 @
{$repos{$reponame}{comments
}} = @comments if $reponame;
42 @
{$groups{$groupname}{comments
}} = @comments if $groupname;
46 } elsif (/^\[repo\s+(.*?)\]$/) {
49 $reponame =~ s/\.git$//;
50 } elsif (/^\[gitosis\]$/) {
53 } elsif (/^gitweb\s*=\s*yes/i) {
54 push @
{$repos{$reponame}{R
}}, 'gitweb';
55 } elsif (/^daemon\s*=\s*yes/i) {
56 push @
{$repos{$reponame}{R
}}, 'daemon';
57 } elsif (/^description\s*=\s*(.+?)$/) {
58 $repos{$reponame}{desc
} = $1;
59 } elsif (/^owner\s*=\s*(.+?)$/) {
60 $repos{$reponame}{owner
} = $1;
61 } elsif (/^\[group\s+(.*)\]$/) {
64 } elsif (/^members\s*=\s*(.*)/) {
65 push @
{$groups{$groupname}{users
}}, map {s/\@([^.]+)$/_$1/g; $_} split(' ', $1);
66 } elsif (/^write?able\s*=\s*(.*)/) {
67 foreach my $repo (split(' ', $1)) {
69 push @
{$repos{$repo}{RW
}}, "\@$groupname";
71 } elsif (/^readonly\s*=\s*(.*)/) {
72 foreach my $repo (split(' ', $1)) {
74 push @
{$repos{$repo}{R
}}, "\@$groupname";
80 #print Dumper(\%repos);
81 #print Dumper(\%groups);
84 print "#\n# Groups\n#\n\n";
85 foreach my $grp (sort keys %groups) {
86 next unless @
{$groups{$grp}{users
}};
87 printf join("\n", @
{$groups{$grp}{comments
}})."\n" if $groups{$grp}{comments
};
88 printf "\@%-19s = %s\n", $grp, join(' ', @
{$groups{$grp}{users
}});
92 print "\n#\n# Gitweb\n#\n\n";
93 foreach my $repo (sort keys %repos) {
94 if ($repos{$repo}{desc
}) {
95 @
{$repos{$repo}{R
}} = grep(!/^gitweb$/, @
{$repos{$repo}{R
}});
97 print " \"$repos{$repo}{owner}\"" if $repos{$repo}{owner
};
98 print " = \"$repos{$repo}{desc}\"\n";
103 print "\n#\n# Repos\n#\n";
104 foreach my $repo (sort keys %repos) {
106 printf join("\n", @
{$repos{$repo}{comments
}})."\n" if $repos{$repo}{comments
};
107 #if ($repos{$repo}{desc}) {
108 # @{$repos{$repo}{R}} = grep(!/^gitweb$/, @{$repos{$repo}{R}});
110 print "repo\t$repo\n";
111 foreach my $access (qw(RW+ RW R)) {
112 next unless $repos{$repo}{$access};
114 foreach my $key (@
{$repos{$repo}{$access}}) {
115 if ($key =~ /^\@(.*)/) {
116 next unless defined $groups{$1} and @
{$groups{$1}{users
}};
120 printf "\t$access\t= %s\n", join(' ', @keys) if @keys;
122 #if ($repos{$repo}{desc}) {
124 # print " \"$repos{$repo}{owner}\"" if $repos{$repo}{owner};
125 # print " = \"$repos{$repo}{desc}\"\n";