delproj.cgi: Fix forks check
[girocco/ztw.git] / cgi / p / delproj.cgi
blobc4d7850e045f3ae8db990662ac7c358b16972592
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib qw(/home/repo/repomgr/cgi);
9 use Git::RepoCGI;
11 my $repo = Git::RepoCGI->new('Project Removal');
12 my $cgi = $repo->cgi;
14 my $name = $cgi->remote_user();
16 if (!valid_proj_name($name)) {
17 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
18 exit;
21 if (!Git::RepoCGI::Project::does_exist($name)) {
22 print "<p>Sorry but this project does not exist. Now, how did you <em>get</em> here?!</p>\n";
23 exit;
26 if (!Git::RepoCGI::Project::available($name)) {
27 print "<p>Sorry but your project has not finished mirroring yet. If it takes inordinate amount of time, please tell the administrator.</p>\n";
28 exit;
31 my $proj = Git::RepoCGI::Project->load($name);
32 $proj or die "not found project $name, that's really weird!";
34 if (!$proj->{mirror}) {
35 print "<p>Sorry but you can remove only mirrored projects. Pushed projects cannot be removed. Please tell the administrator if you really want to.</p>\n";
36 exit;
39 if (glob('/srv/git/'.$name.'/*')) {
40 print "<p>Sorry but this project has forks associated. Such projects cannot be removed. Please tell the administrator if you really want to.</p>\n";
41 exit;
44 if ($cgi->param('y0')) {
45 # submitted
46 $proj->delete;
47 print "<p>Project successfuly deleted. Have a nice day.</p>\n";
48 exit;
51 my $url = $proj->{url};
53 print <<EOT;
54 <p>Please confirm that you are going to remove mirrored project
55 $name ($url) from the site.</p>
56 <form method="post">
57 <p><input type="submit" name="y0" value="Remove" /></p>
58 </form>
59 EOT