[devscripts] 01/01: bts: Cancel the command if a spawned editor errors out

James McCoy jamessan at debian.org
Tue Feb 24 04:41:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit f6053e2f5cfb0d1463e552dfbce0d5b48ffa84d7
Author: James McCoy <jamessan at debian.org>
Date:   Mon Feb 23 23:30:59 2015 -0500

    bts: Cancel the command if a spawned editor errors out
    
    Although this is already supported by saving an empty file, a user may
    rightfully expect that killing the editor itself will prevent bts from
    sending the command email.
    
    Closes: #778648
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog |  3 +++
 scripts/bts.pl   | 14 ++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 5f16fd4..7ab55a6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -28,6 +28,9 @@ devscripts (2.15.1+exp1) UNRELEASED; urgency=medium
     + Fix extraction of uploader's key id.
     * Create a temporary GNUPGHOME to avoid “gpg --list-key” erroring when no
       ~/.gnupg exists.  (Closes: #776209)
+  * bts: Cancel the mail if the spawned editor exits with a non-zero exit
+    code.  This is an alternative way to cancel a command, rather than saving
+    an empty message.  (Closes: #778648)
 
   [ Johannes Schauer ]
   * chdist: Also set Apt::Architectures to prevent foreign architectures from
diff --git a/scripts/bts.pl b/scripts/bts.pl
index b30989c..4b0a956 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -3970,14 +3970,16 @@ sub edit {
 	or die "$progname: writing to temporary file: $!\n";
     print OUT_MAIL $message;
     close OUT_MAIL;
-    system("sensible-editor $filename");
-    open(OUT_MAIL, "<$filename")
-	or die "$progname: reading from temporary file: $!\n";
+    my $rc = system("sensible-editor $filename");
     undef $message;
-    while(<OUT_MAIL>) {
-	$message .= $_;
+    if ($rc == 0) {
+	open(OUT_MAIL, "<$filename")
+	    or die "$progname: reading from temporary file: $!\n";
+	while(<OUT_MAIL>) {
+	    $message .= $_;
+	}
+	close OUT_MAIL;
     }
-    close OUT_MAIL;
     unlink($filename);
     return $message;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list