From 579730154a2d9cf818f0994ac1a3268849d337fb Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Tue, 10 Oct 2006 13:58:59 +0200 Subject: [PATCH] CGI for deleting mirrored projects --- cgi/p/delproj.cgi | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ cgi/regproj.cgi | 3 ++- indextext.html | 2 +- 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100755 cgi/p/delproj.cgi diff --git a/cgi/p/delproj.cgi b/cgi/p/delproj.cgi new file mode 100755 index 0000000..753e773 --- /dev/null +++ b/cgi/p/delproj.cgi @@ -0,0 +1,54 @@ +#!/usr/bin/perl +# (c) Petr Baudis +# GPLv2 + +use strict; +use warnings; + +use lib qw(/home/repo/repomgr/cgi); +use Git::RepoCGI; + +my $repo = Git::RepoCGI->new('Project Removal'); +my $cgi = $repo->cgi; + +my $name = $cgi->remote_user(); + +if (!valid_name($name)) { + print "

Invalid project name. Go away, sorcerer.

\n"; + exit; +} + +if (!Git::RepoCGI::Project::does_exist($name)) { + print "

Sorry but this project does not exist. Now, how did you get here?!

\n"; + exit; +} + +if (!Git::RepoCGI::Project::available($name)) { + print "

Sorry but your project has not finished mirroring yet. If it takes inordinate amount of time, please tell the administrator.

\n"; + exit; +} + +my $proj = Git::RepoCGI::Project->load($name); +$proj or die "not found project $name, that's really weird!"; + +if (!$proj->{mirror}) { + print "

Sorry but you can remove only mirrored projects. Pushed projects cannot be removed.

\n"; + exit; +} + +if ($cgi->param('y0')) { + # submitted + $proj->delete; + print "

Project successfuly deleted. Have a nice day.

\n"; + exit; +} + +my $url = $proj->{url}; + +print <Please confirm that you are going to remove mirrored project +$name ($url) from the site.

+
+

+
+EOT diff --git a/cgi/regproj.cgi b/cgi/regproj.cgi index 1b2cac2..4f1d654 100755 --- a/cgi/regproj.cgi +++ b/cgi/regproj.cgi @@ -49,7 +49,8 @@ It can be hosted in two modes: mirror mode and push mode. In the first mode, we will check another repository at a given URL each hour and mirror any new updates. In the second mode, registered users with appropriate permissions will be able to push to the repository. You currently cannot switch freely between those two modes; -if you want to switch an existing project, please contact the administrator.

+if you want to switch from mirroring to push mode, delete and recreate +the project. If you want to switch the other way, please contact the administrator.

You will need the admin password to adjust project settings later (mirroring URL, list of users allowed to push, project description, ...). Use the project name as the username when asked by the browser.

diff --git a/indextext.html b/indextext.html index 7ed4026..e7fcde3 100644 --- a/indextext.html +++ b/indextext.html @@ -41,7 +41,7 @@ Host repo.or.cz

at the bottom of your ~/.ssh/config.

[ Register your project ] [ Register your user ]

-

[ Adjust project settings ]

+

[ Adjust project settings ]

[ Delete mirrored project ]


-- 2.11.4.GIT