chiark / gitweb /
dgit-repos-server: some better error msgs, more tests
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 5 Mar 2014 18:27:03 +0000 (18:27 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 5 Mar 2014 18:29:08 +0000 (18:29 +0000)
dgit-repos-server
tests/tests/drs-push-rejects

index 33c18f1..add5424 100755 (executable)
@@ -282,25 +282,25 @@ sub readupdates () {
        m/^(\S+) (\S+) (\S+)$/ or die "$_ ?";
        my ($old, $sha1, $refname) = ($1, $2, $3);
        if ($refname =~ m{^refs/tags/(?=debian/)}) {
-           die if defined $tagname;
+           reject "pushing multiple tags!" if defined $tagname;
            $tagname = $'; #';
            $tagval = $sha1;
            reject "tag $tagname already exists -".
                " not replacing previously-pushed version"
                if $old =~ m/[^0]/;
        } elsif ($refname =~ m{^refs/dgit/}) {
-           die if defined $suite;
+           reject "pushing multiple heads!" if defined $suite;
            $suite = $'; #';
            $oldcommit = $old;
            $commit = $sha1;
        } else {
-           die;
+           reject "pushing unexpected ref!";
        }
     }
     STDIN->error and die $!;
 
-    die unless defined $tagname;
-    die unless defined $suite;
+    reject "push is missing tag ref update" unless defined $tagname;
+    reject "push is missing head ref update" unless defined $suite;
     debug " updates ok.";
 }
 
index e3b5c7d..eab44a5 100755 (executable)
@@ -65,6 +65,14 @@ mustfail 'sid != sponge' HEAD:refs/dgit/sponge $push_spec2
 
 prep unstable sid
 mktag
+mustfail 'push is missing tag ref update' $push_spec1
+mustfail 'push is missing head ref update' $push_spec2
+mustfail 'pushing unexpected ref' $push_spec HEAD:refs/wombat
+mustfail 'pushing multiple heads' $push_spec HEAD:refs/dgit/wombat
+mustfail 'pushing multiple tags' $push_spec HEAD:refs/tags/debian/wombat
+
+prep unstable sid
+mktag
 cp $tmp/dm.gpg $tmp/dd.gpg
 mustfail 'key not found in keyrings'