+perl -i -ne '
+ next if $.==1../^$/;
+ next if m/^----/..0;
+ s/\b1\.0-1\b/1.0-2/g;
+ print or die $!;
+' ../basetag
+
+mv-ident () {
+ local f=$tmp/$1
+ if test -e $f; then
+ mv $f $f--$ident
+ fi
+}
+
+next-mangle () {
+ mv-ident tagupl/overall.log
+ mv-ident sendmail.log
+ ident=$1
+}
+
+with-mangled () {
+ local perl=$1
+ perl <../basetag >../badtag-$ident -pe "$perl"
+ git tag -u Senatus -f -s -m "$(cat ../badtag-$ident)" "$tagname"
+
+ t-tagupl-run-drs
+}
+
+expect-quit () {
+ next-mangle "$1"
+ local perl=$2
+ local mstring=$3
+ with-mangled "$perl"
+ grep ": $mstring" ../tagupl/overall.log
+}
+
+expect-email () {
+ next-mangle "$1"
+ local perl=$2
+ local mstring=$3
+ with-mangled "$perl"
+ grep 'Was not successful' ../sendmail.log
+ grep "$mstring" ../sendmail.log
+ grep ": failed, emailed" ../tagupl/overall.log
+}
+
+raw-mangled () {
+ git update-ref refs/tags/$tagname \
+ $(git hash-object -w -t tag ../tagobj-$ident)
+ t-tagupl-run-drs
+}
+
+tagname=test-dummy/1.2
+t-expect-fail E:'failed command: git fetch' \
+t-tagupl-run-drs
+
+tagname=splorf/$v ; expect-quit baddistro '' 'tag name not for us'
+tagname=test-dummy/1,2; expect-quit badver '' 'tag name not for us'
+tagname=test-dummy/$v
+
+expect-quit noplease s/please-upload/plunk/ 'tag missing please-upload'
+
+expect-email vermatch 's/^example release /$&3/' 'reject: version mismatch'
+
+expect-email unkinfo 's/^\[dgit please-upload/$& Rejectme/' \
+ 'unknown dgit info in tag'
+
+expect-quit unkdistro 's/test-dummy/ubuntu/ if m/^\[dgit/' \
+ 'not for this distro'
+
+expect-email notsplit 's/ split / no-split /' 'reject: missing "split"'