chiark / gitweb /
Infra: Allow FRESHREPO to override "tag already exists"
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 14:32:43 +0000 (15:32 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 14:46:56 +0000 (15:46 +0100)
drs-push-rejects test needs updating too.

infra/dgit-repos-server
tests/tests/drs-push-rejects

index f5dd5aa..e2bec01 100755 (executable)
@@ -447,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>) {
@@ -458,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/}) {
@@ -781,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();
 
index df90d22..5f6d04a 100755 (executable)
@@ -160,7 +160,12 @@ mktag
 mustsucceed $push_spec # succeeds
 
 mktag
+mustfail 'push is missing head ref update' $push_spec
+
+git commit --allow-empty -m 'Dummy update'
+mktag
 mustfail 'not replacing previously-pushed version' $push_spec
+git reset --hard HEAD~
 
 prep_dm_mangle () {
        prep unstable sid