Package: reportbug
Version: 7.5.0
Severity: wishlist
Tags: patch

The attached patch implements a new --list-cc-me option, and
corresponding list-cc-me directive in reportbug.conf, that will
X-Debbugs-CC your detected email address.

This makes it possible to have ~/.reportbugrc files that don't hardcode
the user's email address, and that adapt if the user's email address
changes.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.18.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages reportbug depends on:
ii  apt                1.7.0
ii  python3            3.6.6-1
ii  python3-reportbug  7.5.0
ii  sensible-utils     0.0.12

reportbug recommends no packages.

Versions of packages reportbug suggests:
pn  claws-mail                               <none>
pn  debconf-utils                            <none>
ii  debsums                                  2.2.3
pn  dlocate                                  <none>
pn  emacs24-bin-common | emacs25-bin-common  <none>
ii  file                                     1:5.34-2
ii  gnupg                                    2.2.10-3
pn  postfix | exim4 | mail-transport-agent   <none>
pn  python3-urwid                            <none>
pn  reportbug-gtk                            <none>
ii  xdg-utils                                1.1.3-1

Versions of packages python3-reportbug depends on:
ii  apt                1.7.0
ii  file               1:5.34-2
ii  python3            3.6.6-1
ii  python3-apt        1.7.0~rc1
ii  python3-debian     0.1.33
ii  python3-debianbts  2.7.2
ii  python3-requests   2.18.4-2

python3-reportbug suggests no packages.

-- no debconf information
>From 69fae4b4084b061ad0df8c7f4ef861dea7d92087 Mon Sep 17 00:00:00 2001
From: Josh Triplett <j...@joshtriplett.org>
Date: Tue, 9 Oct 2018 16:28:04 -0700
Subject: [PATCH] Add --list-cc-me option to X-Debbugs-CC your detected email
 address

This makes it possible to have ~/.reportbugrc files that don't hardcode
the user's email address, and that adapt if the user's email address
changes.
---
 bin/reportbug        | 13 +++++++++++--
 man/reportbug.1      |  8 ++++++++
 man/reportbug.conf.5 |  5 +++++
 reportbug/utils.py   |  2 ++
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/bin/reportbug b/bin/reportbug
index 750d4c9..3a08edf 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -732,13 +732,13 @@ def offer_configuration(options):
     if stupidmode:
         print('# Disable fallback mode by commenting out the following:', 
file=fp)
         print('no-cc', file=fp)
-        print('header "X-Debbugs-CC: %s"' % email_addy, file=fp)
+        print('list-cc-me', file=fp)
         print('smtphost reportbug.debian.org', file=fp)
     else:
         print('# If nothing else works, remove the # at the beginning', 
file=fp)
         print('# of the following three lines:', file=fp)
         print('#no-cc', file=fp)
-        print('#header "X-Debbugs-CC: %s"' % email_addy, file=fp)
+        print('#list-cc-me', file=fp)
         print('#smtphost reportbug.debian.org', file=fp)
 
     print('# You can add other settings after this line.  See', file=fp)
@@ -868,6 +868,8 @@ def main():
                                                 'specified mail transport 
agent')
     parser.add_option('--list-cc', action='append', dest='listcc',
                       help='send a copy to the specified address')
+    parser.add_option('--list-cc-me', action='store_true', dest='listccme',
+                      help='send a copy to your detected email address')
     parser.add_option('-p', '--print', action='store_true', dest='printonly',
                       help='output the report to standard output only')
     parser.add_option('--report-quiet', action='store_const', dest='sendto',
@@ -1924,6 +1926,13 @@ For more details, please see: 
http://www.debian.org/devel/wnpp/''')
         if not listcc:
             listcc = []
 
+        if self.options.listccme:
+            detected_addr = self.options.email or utils.get_email()[1]
+            if not detected_addr:
+                efail("list-cc-me option specified but email address not 
detected")
+            ewrite("list-cc-me DEBUG: {}".format(detected_addr))
+            listcc += [detected_addr]
+
         if not listcc and mode > MODE_STANDARD and rtype == 'debbugs' and not 
self.options.testmode and not self.options.template and self.options.ccmenu:
             listcc += ui.get_multiline(
                 'Enter any additional addresses this report should be sent to; 
press ENTER after each address.')
diff --git a/man/reportbug.1 b/man/reportbug.1
index 201e3e1..9eda0fa 100644
--- a/man/reportbug.1
+++ b/man/reportbug.1
@@ -232,6 +232,14 @@ number is assigned; this is the equivalent to the option
 \fI\-H 'X\-Debbugs\-CC: ADDRESS'\fP.  This option will only work as
 intended with \fBdebbugs\fP systems.
 .TP
+.B \-\-list\-cc-me
+Send a carbon copy of the report to your automatically detected email address
+after a report number is assigned. This sets an \fIX\-Debbugs\-CC\fP header
+specifying that address. This option will only work as intended with
+\fBdebbugs\fP systems. See the documentation for the \fI\-\-email\fP option and
+the \fIENVIRONMENT\fP section for information on how reportbug detects your
+email address.
+.TP
 .B \-m, \-\-maintonly
 Only send the bug to the package maintainer; the bug tracking system
 will not send a copy to the bug report distribution lists.
diff --git a/man/reportbug.conf.5 b/man/reportbug.conf.5
index 3493889..1c18f92 100644
--- a/man/reportbug.conf.5
+++ b/man/reportbug.conf.5
@@ -96,6 +96,11 @@ Specify the Envelope From mail header (also known as 
Return-path); by default
 it's the From address but it can be selected a different one in case the MTA
 doesn't canonicalize local users to public addresses.
 
+.TP
+.B list-cc-me (\fIboolean\fP)
+Send a carbon copy of the report to your automatically detected email address
+after a report number is assigned, like the \fI\-\-list\-cc\-me\fP option.
+
 .TP
 .B mbox_reader_cmd
 Specify a command to open the bug reports mbox file. You can use
diff --git a/reportbug/utils.py b/reportbug/utils.py
index a3d5083..993e2a2 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -991,6 +991,8 @@ def parse_config_files():
                     args['nocc'] = (token == 'no-cc')
                 elif token in ('no-compress', 'compress'):
                     args['nocompress'] = (token == 'no-compress')
+                elif token in ('no-list-cc-me', 'list-cc-me'):
+                    args['listccme'] = (token == 'list-cc-me')
                 elif token in ('no-query-bts', 'query-bts'):
                     args['dontquery'] = (token == 'no-query-bts')
                 elif token in ('config-files', 'no-config-files'):
-- 
2.19.1

Reply via email to