Skip to content

Commit 5bab6e2

Browse files
committed
[WIP] Run cc.cmd per on a patch basis
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
1 parent c042ca8 commit 5bab6e2

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

git-publish

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import time
2323
import shutil
2424
import subprocess
2525
import locale
26+
import mailbox
2627
from email import message_from_file, header
2728

2829
VERSION = '1.5.0'
@@ -816,11 +817,31 @@ branch.%s.pushRemote is set appropriately? (Override with --no-url-check)''' %
816817
if options.annotate:
817818
edit(*patches)
818819
if cc_cmd:
820+
s_cc = set()
819821
for x in patches:
820822
output = subprocess.check_output(cc_cmd + " " + x,
821823
shell=True, cwd=git_get_toplevel_dir()).decode(ENCODING)
822-
cc = cc.union(output.splitlines())
823-
cc.difference_update(to)
824+
p_cc = output.splitlines()
825+
if len(p_cc) == 0:
826+
continue
827+
s_cc = s_cc.union(p_cc)
828+
msg = mailbox.Message(open(x).read().encode(ENCODING))
829+
if 'Cc' in msg.keys():
830+
m_cc = msg.get('Cc').split(',')
831+
msg.replace_header('Cc', ','.join(set(m_cc).union(p_cc)))
832+
else:
833+
msg.add_header('Cc', ','.join(p_cc))
834+
open(x, 'w').write(msg.as_string().decode(ENCODING))
835+
if message:
836+
x = os.path.join(tmpdir, '0000-cover-letter.patch')
837+
msg = mailbox.Message(open(x).read().encode(ENCODING))
838+
if 'Cc' in msg.keys():
839+
c_cc = msg.get('Cc').split(',')
840+
msg.replace_header('Cc', ','.join(set(c_cc).union(s_cc)))
841+
else:
842+
msg.add_header('Cc', ','.join(s_cc))
843+
open(x, 'w').write(msg.as_string().decode(ENCODING))
844+
824845
if inspect_emails:
825846
selected_patches = inspect_menu(tmpdir, to, cc, patches, suppress_cc,
826847
options.in_reply_to, topic,

0 commit comments

Comments
 (0)