chiark / gitweb /
WIP nmu before do email stuff
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 28 Dec 2016 12:50:58 +0000 (12:50 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 12 Jan 2017 01:36:00 +0000 (01:36 +0000)
dgit

diff --git a/dgit b/dgit
index 19745818079d2939ca95e68688c9006ccbe0d8f3..c51085698689bac7f574d91bc2784212bca7b381 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -69,6 +69,7 @@ our $rmchanges;
 our $overwrite_version; # undef: not specified; '': check changelog
 our $quilt_mode;
 our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|dpm|unapplied';
+our $delayed;
 our $dodep14tag;
 our $split_brain_save;
 our $we_are_responder;
@@ -590,6 +591,7 @@ our %defcfg = ('dgit.default.distro' => 'debian',
               'dgit-distro.debian.git-check' => 'url',
               'dgit-distro.debian.git-check-suffix' => '/info/refs',
               'dgit-distro.debian.new-private-pushers' => 't',
+              'dgit-distro.debian.nmudiff-qateam' => 'packages@qa.debian.org',
               'dgit-distro.debian/push.git-url' => '',
               'dgit-distro.debian/push.git-host' => 'push.dgit.debian.org',
               'dgit-distro.debian/push.git-user-force' => 'dgit',
@@ -4021,6 +4023,104 @@ sub sign_changes ($) {
     }
 }
 
+sub nmudiff_email_prepare ($) {
+    my ($changes) = @_;
+    if ($donmudiff eq 'no') {
+       return;
+    } elsif ($donmudiff eq 'always') {
+    } elsif ($donmudiff eq 'auto') {
+       my %maints;
+       foreach my $f qw(Maintainer Uploaders) {
+           my $maints = $dsc->{$f};
+           next unless defined $maints;
+           $maints{ $_->address }=1 foreach parse Mail::Address $maints;
+       }
+       return unless grep { defined && $maints{$_} },
+           (access_cfg 'nmudiff-qateam', 'RETURN-UNDEF'),
+           (getfield $changes, 'Changed-By');
+       progress
+           "NMU (neither QA nor Changed-By is in Maintainer/Uploaders).";
+    } else {
+       die $donmudiff;
+    }
+
+    my @closes = split /\s+/, $dctrl->{Closes} // '';
+    if (@closes==1) {
+       push @header, <<END;
+To: $closes[0]\@$domain
+Subject: #$closes[0]: Fixed in NMU ($package $version)
+END
+    } else {
+       push @header, <<END;
+To: $newbug
+Subject: $source: diff for NMU version $version
+END
+    }
+    push @header, <<END:
+X-Mailer: dgit ($our_version)
+END
+
+    push @body, <<END;
+Dear Maintainer,
+
+I've prepared an NMU for $package, version $version.
+END
+
+    if (defined $delayed) {
+       push @psuedoheader, <<END;
+Control: tags -1 + patch
+Control: fixed -1 $version
+END
+       push @body, <<END:
+I have just uploaded it to DELAYED/$delay.
+END
+    } else {
+       push @pseudoheader, <<END foreach @closes;
+Control: tags $_ + patch
+Control: fixed $_ $version
+END
+       push @body, <<END:
+I have just uploaded it to $csuite.
+END
+    }
+
+    push @body, <<END;
+
+The diff is attached to this message.
+
+FYI I used git and dgit to prepare the new version.
+You can find my changes as git commits in the dgit git repository:
+END
+    my @urls;
+    push @urls, access_giturl;
+    my $u2= do { local $access_forpush=0; access_giturl; };
+    push @urls, $u2 unless grep { $_ eq $u2 } @urls;
+    push @body, "  ",$_,"\n" foreach @urls;
+    push @body, <<END;
+in the remote ref
+  refs/dgit/$csuite xxx
+so e.g.
+  git fetch $urls[0] xxx
+  git log FETCH_HEAD
+
+My commits are from $previous
+(previous dgit tip for $csuite)
+to $current ($tagname):
+END
+    if (madformat) {
+       push @body, <<END;
+If you are not a dgit user, depending on your own git workflow, you
+may want to: cherry pick the relevant individual changes; rebase
+(perhaps selectively); and/or copy (perhaps dgit-generated) patches
+from debian/patches/.
+END
+    } else {
+       push @body, <<END;
+If you are not a dgit user, depending on your own git workflow, you
+may want to rebase the dgit branch onto your own history.
+END
+    }
+
 sub dopush () {
     printdebug "actually entering push\n";
 
@@ -4175,6 +4275,8 @@ END
 
     # Checks complete, we're going to try and go ahead:
 
+    numdiff_email_prepare($changes);
+
     responder_send_file('changes',$changesfile);
     responder_send_command("param head $dgithead");
     responder_send_command("param csuite $csuite");
@@ -6397,6 +6499,7 @@ sub parseopts () {
                push @ropts, $_;
                $overwrite_version = $1;
            } elsif (m/^--delayed=(\d+)$/s) {
+               $delayed= $1 + 0;
                push @ropts, $_;
                push @dput, $_;
            } elsif (m/^--dgit-view-save=(.+)$/s) {