2 # (c) Petr Baudis <pasky@suse.cz>
14 my $gcgi = Girocco
::CGI
->new('Project Mirroring');
17 my $name = $cgi->param('name');
18 $name =~ s
#\.git$## if $name; #
20 unless (defined $name) {
21 print "<p>I need the project name as an argument now.</p>\n";
25 if (!Girocco
::Project
::does_exist
($name,1) && !Girocco
::Project
::valid_name
($name)) {
26 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
30 if (!Girocco
::Project
::does_exist
($name,1)) {
31 print "<p>Sorry but the project $name does not exist. Now, how did you <em>get</em> here?!</p>\n";
35 my $proj = Girocco
::Project
->load($name);
37 print "<p>not found project $name, that's really weird!</p>\n";
41 $escname =~ s/[+]/%2B/g;
43 if (!$proj->{mirror
}) {
44 print "<p>This project is not a mirror to be cloned.</p>\n";
51 if (!$proj->{clone_logged
} or $proj->{clone_failed
}) {
52 # Kick off the clone since it is not running yet
53 print "<p>Initiated mirroring of ".$proj->{url
}." to $Girocco::Config::name project ".
54 "<a href=\"@{[url_path($Girocco::Config::gitweburl)]}/$name.git\">$name</a>.git:</p>\n";
56 } elsif ($proj->{clone_in_progress
}) {
57 print "<p>Mirroring of ".$proj->{url
}." to $Girocco::Config::name project ".
58 "<a href=\"@{[url_path($Girocco::Config::gitweburl)]}/$name.git\">$name</a>.git in progress:</p>\n";
60 print "<p>Mirroring of ".$proj->{url
}." to $Girocco::Config::name project ".
61 "<a href=\"@{[url_path($Girocco::Config::gitweburl)]}/$name.git\">$name</a>.git completed:</p>\n";
66 open LOG
, '<', $proj->_clonelog_path() and last;
70 print "<p>Mirroring has not yet started, there may be a clone backlog.</p>\n";
71 print "<p>Please <a href=\"@{[url_path($Girocco::Config::webadmurl)]}/mirrorproj.cgi?name=$escname\">reload this page</a> again later.</p>\n";
79 for ($curpos = tell(LOG
); <LOG
>; $curpos = tell(LOG
)) {
81 $_ eq '@OVER@' and last tailf
;
85 seek(LOG
, $curpos, 0); # seek to where we had been
90 $proj = Girocco
::Project
->load($name);
91 $proj or die "not found project $name on second load, that's _REALLY_ weird!";
93 if ($proj->{clone_failed
}) {
95 <p><strong>Mirroring failed!</strong> Please <a
96 href="@{[url_path($Girocco::Config::webadmurl)]}/editproj.cgi?name=$escname"
97 >revisit the project settings</a>.</p>