chiark / gitweb /
Infra: Allow FRESHREPO to override "tag already exists"
[dgit.git] / infra / dgit-repos-server
index d990aeea5e3c2f2682ac48573701579f20168a20..e2bec01e810b1dc512a2e7851a66934ae466282d 100755 (executable)
@@ -126,6 +126,8 @@ $SIG{__WARN__} = sub { die $_[0]; };
 #   POLICY-HOOK-SCRIPT ... push-confirm PACKAGE \
 #         VERSION SUITE TAGNAME DELIBERATELIES FRESH-REPO|'' [...]
 #
+# DELIBERATELIES is like this: --deliberately-foo,--deliberately-bar,...
+#
 # Exit status is a bitmask.  Bit weight constants are defined in Dgit.pm.
 #    NOFFCHECK   (2)
 #         suppress dgit-repos-server's fast-forward check ("push" only)
@@ -319,7 +321,7 @@ sub movetogarbage () {
 
     ensuredir "$dgitrepos/_removed-tags";
     open PREVIOUS, ">>", removedtagsfile or die removedtagsfile." $!";
-    git_for_each_ref(debiantag('*'), sub {
+    git_for_each_ref('refs/tags/'.debiantag('*'), sub {
        my ($objid,$objtype,$fullrefname,$reftail) = @_;
        print PREVIOUS "\n$objid $reftail .\n" or die $!;
     }, $real);
@@ -445,6 +447,8 @@ sub main__git_receive_pack () {
 our ($tagname, $tagval, $suite, $oldcommit, $commit);
 our ($version, %tagh);
 
+our ($tagexists_error);
+
 sub readupdates () {
     printdebug " updates ...\n";
     while (<STDIN>) {
@@ -456,7 +460,7 @@ sub readupdates () {
            reject "pushing multiple tags!" if defined $tagname;
            $tagname = $'; #';
            $tagval = $sha1;
-           reject "tag $tagname already exists -".
+           $tagexists_error= "tag $tagname already exists -".
                " not replacing previously-pushed version"
                if $old =~ m/[^0]/;
        } elsif ($refname =~ m{^refs/dgit/}) {
@@ -736,7 +740,7 @@ sub checktagnoreplay () {
                my ($tagobjid,$refobjid,$fullrefname,$tagname) = @_;
                $check_ref_superseded->($tagobjid,undef,$fullrefname,undef);
             });
-           printdebug "checktagnoreply - not FRESHREPO, nchecked=$nchecked";
+           printdebug "checktagnoreplay - not FRESHREPO, nchecked=$nchecked";
            push @problems, "does not supersede any tag".
                " referring to branch head $branch=$branchhead"
                unless $nchecked;
@@ -749,7 +753,7 @@ sub checktagnoreplay () {
            join("; ", @problems).
            "\n";
     }
-    printdebug "checktagnoreply - all ok\n"
+    printdebug "checktagnoreplay - all ok ($tagval)\n"
 }
 
 sub tagh1 ($) {
@@ -779,6 +783,14 @@ sub checks () {
                    join(",",@deliberatelies));
     $policy = policyhook(NOFFCHECK|FRESHREPO, 'push', @policy_args);
 
+    if (defined $tagexists_error) {
+       if ($policy & FRESHREPO) {
+           printdebug "ignoring tagexists_error: $tagexists_error\n";
+       } else {
+           reject $tagexists_error;
+       }
+    }
+
     checktagnoreplay();
     checksuite();