chiark / gitweb /
dgit: Be more careful about tag updates during fetch: only update tags referring...
[dgit.git] / infra / dgit-repos-server
index 5a87b891b4bc14e2e9b281fce3e476ec1ac23504..ae25aaa3bc1c7579fdc4ffcd302b4acf281ebda5 100755 (executable)
@@ -62,7 +62,7 @@ $SIG{__WARN__} = sub { die $_[0]; };
 #   as a result of this the stunt pre-receive hook runs; it does this:
 #    + understand what refs we are allegedly updating and
 #      check some correspondences:
-#        * we are updating only refs/tags/debian/* and refs/dgit/*
+#        * we are updating only refs/tags/DISTRO/* and refs/dgit/*
 #        * and only one of each
 #        * and the tag does not already exist
 #      and
@@ -163,7 +163,8 @@ $SIG{__WARN__} = sub { die $_[0]; };
 # appropriate lock.
 #
 # If policy hook wants to run dgit (or something else in the dgit
-# package), it should use DGIT-LIVE-DIR/dgit (etc.)
+# package), it should use DGIT-LIVE-DIR/dgit (etc.), or if that is
+# ENOENT, use the installed version.
 
 
 use POSIX;
@@ -290,10 +291,11 @@ sub mkemptyrepo ($$) {
 sub mkrepo_fromtemplate ($) {
     my ($dir) = @_;
     my $template = "$dgitrepos/_template";
-    locksometree($template);
+    my $templatelock = locksometree($template);
     printdebug "copy template $template -> $dir\n";
     my $r = system qw(cp -a --), $template, $dir;
     !$r or die "create new repo $dir failed: $r $!";
+    close $templatelock;
 }
 
 sub movetogarbage () {
@@ -321,7 +323,7 @@ sub movetogarbage () {
 
     ensuredir "$dgitrepos/_removed-tags";
     open PREVIOUS, ">>", removedtagsfile or die removedtagsfile." $!";
-    git_for_each_ref('refs/tags/'.debiantag('*'), sub {
+    git_for_each_ref('refs/tags/'.debiantag('*',$distro), sub {
        my ($objid,$objtype,$fullrefname,$reftail) = @_;
        print PREVIOUS "\n$objid $reftail .\n" or die $!;
     }, $real);
@@ -456,7 +458,7 @@ sub readupdates () {
        printdebug " upd.| $_\n";
        m/^(\S+) (\S+) (\S+)$/ or die "$_ ?";
        my ($old, $sha1, $refname) = ($1, $2, $3);
-       if ($refname =~ m{^refs/tags/(?=debian/)}) {
+       if ($refname =~ m{^refs/tags/(?=$distro/)}) {
            reject "pushing multiple tags!" if defined $tagname;
            $tagname = $'; #';
            $tagval = $sha1;
@@ -729,7 +731,7 @@ sub checktagnoreplay () {
        }
     } else {
        my $branch= server_branch($suite);
-       my $branchhead= git_get_ref($branch);
+       my $branchhead= git_get_ref(server_ref($suite));
        if (!length $branchhead) {
            # No such branch - NOFFCHECK was unnecessary.  Oh well.
            printdebug "checktagnoreplay - not FRESHREPO, new branch, ok\n";
@@ -771,11 +773,9 @@ sub checks () {
     tagh1('object') eq $commit or reject "tag refers to wrong commit";
     tagh1('tag') eq $tagname or reject "tag name in tag is wrong";
 
-    my $v = $version;
-    $v =~ y/~:/_%/;
-
-    printdebug "translated version $v\n";
-    $tagname eq "debian/$v" or die;
+    my $expecttagname = debiantag $version, $distro;
+    printdebug "expected tag $expecttagname\n";
+    $tagname eq $expecttagname or die;
 
     lockrealtree();