X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=infra%2Fdgit-repos-server;h=bbf1aa215a34e054b5b4532254865365c7f6e3b4;hp=828ab7a14b66ec4cff9a9404e3a3bf4053620198;hb=HEAD;hpb=56dac689f66baa1d9e5c2e25dd2f5ef78fdb1db2 diff --git a/infra/dgit-repos-server b/infra/dgit-repos-server index 828ab7a1..bbf1aa21 100755 --- a/infra/dgit-repos-server +++ b/infra/dgit-repos-server @@ -3,7 +3,7 @@ # # git protocol proxy to check dgit pushes etc. # -# Copyright (C) 2014-2016 Ian Jackson +# Copyright (C) 2014-2017,2019 Ian Jackson # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -591,7 +591,8 @@ sub parsetag_general ($$) { if ($dgititemfn->()) { } elsif (s/^distro\=(\S+) //) { $distrofn->($1); - } elsif (s/^[-+.=0-9a-z]\S* //) { + } elsif (s/^([-+.=0-9a-z]\S*) //) { + printdebug " parsetag ignoring unrecognised \`$1'\n"; } else { die "unknown dgit info in tag ($_)"; } @@ -783,7 +784,7 @@ sub checktagnoreplay () { # current head for the suite (there must be at least one). # # This prevents any tag implying a NOFFCHECK push being - # replayed to rewind from a different head. + # replayed to overwrite a different head. # # The possibility of an earlier ff-only push being replayed is # eliminated as follows: the tag from such a push would still @@ -1073,10 +1074,10 @@ our @hookenvs = qw(distro suitesfile suitesformasterfile policyhook # workrepo and destrepo handled ad-hoc sub mode_tag2upload () { - # PROTOTYPE # CALLER MUST PREVENT MULTIPLE CONCURRENT RUNS IN SAME CWD # If we fail (exit nonzero), caller should capture our stderr, # and retry some bounded number of times in some appropriate way + # Uses whatever ambient gpg key is available @ARGV==2 or die; my $url; @@ -1132,7 +1133,7 @@ sub mode_tag2upload () { # quick and dirty check, will check properly later m/^\[dgit[^"]* please-upload(?:\]| )/m or - $quit->("tag missing please-upload request $_"); + $quit->("tag missing please-upload request"); m/^tagger (.*) \d+ [-+]\d+$/m or $quit->("failed to fish tagger out of tag"); @@ -1149,7 +1150,6 @@ sub mode_tag2upload () { # This is for us. From now on, we will capture errors to # be emailed to the tagger. - # TODO: failures to git fetch from salsa will burn a version open H, ">>dgit-tmp/tagupl.email" or die $!; print H <("failed, emailed"); } open STDERR, ">&L" or die $!; open STDOUT, ">&STDERR" or die $!; open DEBUG, ">&STDERR" if $debuglevel; - die "$tagmversion != $version " unless $tagmversion eq $version; + reject "version mismatch $tagmversion != $version " + unless $tagmversion eq $version; my %need = map { $_ => 1 } qw(please-upload split); my ($upstreamc, $upstreamt); @@ -1213,7 +1214,7 @@ END $upstreamc = $1; } elsif (s/^upstream-tag=(\S+) //) { $upstreamt = $1; - } elsif (s/^quilt=([-+0-9a-z]+) //) { + } elsif (s/^--quilt=([-+0-9a-z]+) //) { $quilt = $1; } else { return 0; @@ -1224,15 +1225,15 @@ END $distro_ok ||= $gotdistro eq $distro; }; - $quit->("other distro") unless $distro_ok; + $quit->("not for this distro") unless $distro_ok; reject "missing \"$_\"" foreach keys %need; + verifytag(); + reject "upstream tag and not commitish, or v-v" unless defined $upstreamt == defined $upstreamc; - verifytag(); - my @dgit; push @dgit, $ENV{DGIT_DRS_DGIT} // 'dgit'; push @dgit, '-wn'; @@ -1244,7 +1245,6 @@ END my @fetch = qw(git fetch origin --unshallow); if (defined $upstreamt) { - runcmd qw(git check-ref-format), "refs/tags/$upstreamt"; runcmd qw(git check-ref-format), "refs/tags/$upstreamt"; my $utagref = "refs/tags/$upstreamt"; push @fetch, "$utagref:$utagref"; @@ -1253,7 +1253,17 @@ END runcmd qw(git checkout -q), "refs/tags/$tagval"; - @fetch = (@dgit, qw(fetch), $suite); + my $clogp = parsechangelog(); + my $clogf = sub { + my ($f, $exp) = @_; + my $got = getfield $clogp, $f; + return if $got eq $exp; + reject "mismatch: changelog $f $got != $exp"; + }; + $clogf->('Version', $version); + $clogf->('Source', $package); + + @fetch = (@dgit, qw(--for-push fetch), $suite); debugcmd "+",@_; $!=0; $?=-1; if (system @fetch) { @@ -1261,7 +1271,9 @@ END } # this is just to get the orig, so we don't really care about the ref if (defined $upstreamc) { - $upstreamc eq git_rev_parse "refs/tags/$upstreamt" or die; + my $need_upstreamc = git_rev_parse "refs/tags/$upstreamt"; + $upstreamc eq $need_upstreamc or reject + "upstream-commitish=$upstreamc but tag refers to $need_upstreamc"; runcmd qw(git deborig), "$upstreamc"; } @@ -1271,12 +1283,12 @@ END if (defined $quilt) { push @dgitcmd, "--quilt=$quilt"; if ($quilt =~ m/baredebian/) { - die "needed upstream commmitish with --quilt=baredebian"; - push @dgitcmd, "--upstream-commitish=$upstreamc"; + die "needed upstream commmitish with --quilt=baredebian" + unless defined $upstreamc; + push @dgitcmd, "--upstream-commitish=refs/tags/$upstreamt"; } } push @dgitcmd, qw(push-source --new --overwrite), $suite; - # xxx what about the key to use? runcmd @dgitcmd;