chiark / gitweb /
dgit-repos-server: Break out movetogarbage
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 21 Mar 2015 11:55:13 +0000 (11:55 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Mar 2015 15:19:50 +0000 (15:19 +0000)
infra/dgit-repos-server

index 734fd71..ed27c0e 100755 (executable)
@@ -213,6 +213,15 @@ sub mkrepo_fromtemplate ($) {
     !$r or die "create new repo $dir failed: $r $!";
 }
 
+sub movetogarbage () {
+    my $garbagerepo = "$dgitrepos/_tmp/${package}_garbage";
+    acquiretree($garbagerepo,1);
+    rmtree $garbagerepo;
+    rename $realdestrepo, $garbagerepo
+       or $! == ENOENT
+       or die "rename repo $realdestrepo to $garbagerepo: $!";
+}
+
 #----- git-receive-pack -----
 
 sub fixmissing__git_receive_pack () {
@@ -642,12 +651,7 @@ sub parseargsdispatch () {
 
     my ($policy, $pollock) = policyhook(FRESHREPO,'check-package',$package);
     if ($policy & FRESHREPO) {
-       my $garbagerepo = "$dgitrepos/_tmp/${package}_garbage";
-       acquiretree($garbagerepo,1);
-       rmtree $garbagerepo;
-       rename $realdestrepo, $garbagerepo
-           or $! == ENOENT
-           or die "rename repo $destrepo to $garbagerepo: $!";
+       movetogarbage;
     }
     close $pollock or die $!;