chiark / gitweb /
quiltify_dpkg_commit: Improve
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 5c8d24a7908eb891ef1ebf5765593100683f47e7..af9576670a3fa219e8d991e6b16872510c3fd2f6 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -163,7 +163,10 @@ sub waitstatusmsg () {
 sub printdebug { print DEBUG $debugprefix, @_ or die $!; }
 
 sub fail { 
-    die $us.($we_are_responder ? " (build host)" : "").": @_\n";
+    my $s = "@_\n";
+    my $prefix = $us.($we_are_responder ? " (build host)" : "").": ";
+    $s =~ s/^/$prefix/gm;
+    die $s;
 }
 
 sub badcfg { print STDERR "$us: invalid configuration: @_\n"; exit 12; }
@@ -2036,30 +2039,25 @@ our $dscfn;
 
 our $fakeeditorenv = 'DGIT_FAKE_EDITOR_QUILT';
 
-sub quiltify ($$) {
-    my ($clogp,$headref) = @_;
+sub quiltify_dpkg_commit ($$$;$) {
+    my ($patchname,$author,$msg, $xinfo) = @_;
+    $xinfo //= '';
 
-    my $author = getfield $clogp, 'Maintainer';
-    my $time = time;
-    my $ncommits = 3;
-    my $patchname = "auto-$version-$headref-$time";
-    my $msg = cmdoutput @git, qw(log), "-n$ncommits";
     mkpath '.git/dgit';
     my $descfn = ".git/dgit/quilt-description.tmp";
     open O, '>', $descfn or die "$descfn: $!";
+    $msg =~ s/\s+$//g;
     $msg =~ s/\n/\n /g;
     $msg =~ s/^\s+$/ ./mg;
     print O <<END or die $!;
-Description: Automatically generated patch ($clogp->{Version})
- Last (up to) $ncommits git changes, FYI:
- .
- $msg
+Description: $msg
 Author: $author
-
+$xinfo
 ---
 
 END
     close O or die $!;
+
     {
        local $ENV{'EDITOR'} = cmdoutput qw(realpath --), $0;
        local $ENV{'VISUAL'} = $ENV{'EDITOR'};
@@ -2068,6 +2066,19 @@ END
     }
 }
 
+sub quiltify ($$) {
+    my ($clogp,$headref) = @_;
+
+    my $time = time;
+    my $ncommits = 3;
+    my $msg = cmdoutput @git, qw(log), "-n$ncommits";
+
+    quiltify_dpkg_commit "auto-$version-$headref-$time",
+        (getfield $clogp, 'Maintainer'),
+        "Automatically generated patch ($clogp->{Version})\n".
+        "Last (up to) $ncommits git changes, FYI:\n\n". $msg;
+}
+
 sub build_maybe_quilt_fixup () {
     my $format=get_source_format;
     return unless madformat $format;