3 # Send a project to the trash
18 undef(*CORE
::GLOBAL
::die);
19 *CORE
::GLOBAL
::die = \
&mydie
;
21 my $bin = $Girocco::Config
::reporoot
.'-recyclebin';
24 my $project = shift @ARGV || die "Please give project name on command line.";
27 # Physical removal isn't actually supported. You have to do it manually.
28 # This only deletes the project from the list.
30 if ($project eq '--really-delete') {
32 $project = shift @ARGV || die "Please give project name on command line.";
36 # Don't use this option while jobd is running. You run the risk of destroying data.
38 if ($project eq '--keep-forks') {
40 $project = shift @ARGV || die "Please give project name on command line.";
43 my $p = Girocco
::Project
->load($project) || die "Project '$project' not found!";
46 # Run GC on that repository so that objects don't get lost within forks
47 my $reporoot = $Girocco::Config
::reporoot
;
48 my $basedir = $Girocco::Config
::basedir
;
49 print "We have to run GC on the repo so that the forks don't lose data. Hang on...\n";
50 system("GIT_DIR=$reporoot/$project.git git config --unset gitweb.lastgc");
51 system("show_progress=1 $basedir/jobd/gc.sh $project");
53 die "Complicated situation: project still has forks. Please deal with it manually."
54 if (-d
"$Girocco::Config::reporoot/$project/");
58 use POSIX
qw(strftime);
59 die "Already have a deleted version of the project. You need to make a decision now."
60 if (-d
"$bin/$project.git");
62 if ($project =~ m!/!) {
63 my $parent = $project; $parent =~ s{^(.+)/.*$}{$1};
64 system("mkdir -p '$bin/$parent'") == 0 || die "Problem creating directory hierarchy in recycle bin: $!";
67 rename $p->{'path'}, "$bin/$project.git" || die "Problem moving project data: $!";
68 my ($S,$M,$H,$d,$m,$y) = gmtime(time());
69 my $recycletime = strftime
("%Y-%m-%dT%H:%M:%SZ", $S, $M, $H, $d, $m, $y, -1, -1, -1);
70 system("GIT_DIR=$bin/$project.git git config girocco.recycletime $recycletime");
73 print "Project '$project' removed from repo.or.cz". ($delete ?
'' : ", backup in $bin/$project.git") .".\n";