summaryrefslogtreecommitdiff
path: root/infra
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2016-09-19 01:34:55 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2016-09-25 20:12:52 +0100
commitff53225eafcc9e53998f9f49085a366f3f98fc9c (patch)
treee1b7a52878fb18d59ad9b8728477402856a8eb2c /infra
parentf161f45247f812f366a76e039035255450d4e522 (diff)
Split brain: dgit-repos-server: Permit pushing maintainer tag too
Split brain is going to need the maintainer tag on the dgit server. Allow clients to push the _both_ the DEP-14 and new dgit archive/ tag. In this case dgit-repos-server can largely ignore the DEP-14 tag. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'infra')
-rwxr-xr-xinfra/dgit-repos-server33
1 files changed, 25 insertions, 8 deletions
diff --git a/infra/dgit-repos-server b/infra/dgit-repos-server
index f7d1b04..5bf4416 100755
--- a/infra/dgit-repos-server
+++ b/infra/dgit-repos-server
@@ -445,23 +445,25 @@ sub maybeinstallprospective () {
exec qw(git show-ref);
die $!;
}
- my %got = qw(tag 0 head 0);
+ my %got = qw(newtag 0 omtag 0 head 0);
while (<SR>) {
chomp or die;
printdebug " show-refs| $_\n";
s/^\S*[1-9a-f]\S* (\S+)$/$1/ or die;
next if m{^refs/heads/master$};
my $wh =
- m{^refs/tags/} ? 'tag' :
+ m{^refs/tags/archive/} ? 'newtag' :
+ m{^refs/tags/} ? 'omtag' :
m{^refs/dgit/} ? 'head' :
die;
+ use Data::Dumper;
die if $got{$wh}++;
}
$!=0; $?=0; close SR or $?==256 or die "$? $!";
printdebug "installprospective ?\n";
die Dumper(\%got)." -- missing refs in new repo"
- if grep { !$_ } values %got;
+ unless $got{head} && grep { m/tag$/ && $got{$_} } keys %got;
lockrealtree();
@@ -487,21 +489,22 @@ sub main__git_receive_pack () {
our ($tagname, $tagval, $suite, $oldcommit, $commit);
our ($version, %tagh);
+our ($maint_tagname, $maint_tagval);
our ($tagexists_error);
sub readupdates () {
printdebug " updates ...\n";
+ my %tags;
while (<STDIN>) {
chomp or die;
printdebug " upd.| $_\n";
m/^(\S+) (\S+) (\S+)$/ or die "$_ ?";
my ($old, $sha1, $refname) = ($1, $2, $3);
if ($refname =~ m{^refs/tags/(?=(?:archive/)?$distro/)}) {
- reject "pushing multiple tags!" if defined $tagname;
- $tagname = $'; #';
- $tagval = $sha1;
- $tagexists_error= "tag $tagname already exists -".
+ my $tn = $'; #';
+ $tags{$tn} = $sha1;
+ $tagexists_error= "tag $tn already exists -".
" not replacing previously-pushed version"
if $old =~ m/[^0]/;
} elsif ($refname =~ m{^refs/dgit/}) {
@@ -515,7 +518,19 @@ sub readupdates () {
}
STDIN->error and die $!;
- reject "push is missing tag ref update" unless defined $tagname;
+ reject "push is missing tag ref update" unless %tags;
+ my @newtags = grep { m#^archive/# } keys %tags;
+ my @omtags = grep { !m#^archive/# } keys %tags;
+ reject "pushing too many similar tags" if @newtags>1 || @omtags>1;
+ if (@newtags) {
+ ($tagname) = @newtags;
+ ($maint_tagname) = @omtags;
+ } else {
+ ($tagname) = @omtags or die;
+ }
+ $tagval = $tags{$tagname};
+ $maint_tagval = $tags{$maint_tagname // ''};
+
reject "push is missing head ref update" unless defined $suite;
printdebug " updates ok.\n";
}
@@ -883,6 +898,8 @@ sub onwardpush () {
my @cmd = @cmdbase;
push @cmd, "$commit:refs/dgit/$suite",
"$tagval:refs/tags/$tagname";
+ push @cmd, "$maint_tagval:refs/tags/$maint_tagname"
+ if defined $maint_tagname;
debugcmd '+',@cmd;
$!=0;
my $r = system @cmd;