From b860e96fe695b73fde356da72ec70172189fbff7 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 14 Dec 2020 13:58:42 -0500 Subject: Allow passing extra opts to git-format-patch We probably want to be able to tweak the output of git-format-patch based on which list we're running it for (e.g. passing --minimal or --histogram), so make it possible to pass extra parameters to the git command. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 4 +++- b4/pr.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 432a8cd..e936781 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -2335,11 +2335,13 @@ def get_pi_thread_by_msgid(msgid, savefile, useproject=None, nocache=False): @contextmanager -def git_format_patches(gitdir, start, end, prefixes=None): +def git_format_patches(gitdir, start, end, prefixes=None, extraopts=None): with TemporaryDirectory() as tmpd: gitargs = ['format-patch', '--cover-letter', '-o', tmpd, '--signature', f'b4 {__VERSION__}'] if prefixes is not None and len(prefixes): gitargs += ['--subject-prefix', ' '.join(prefixes)] + if extraopts: + gitargs += extraopts gitargs += ['%s..%s' % (start, end)] ecode, out = git_run_command(gitdir, gitargs) if ecode > 0: diff --git a/b4/pr.py b/b4/pr.py index ef390a2..e31afc1 100644 --- a/b4/pr.py +++ b/b4/pr.py @@ -239,7 +239,7 @@ def thanks_record_pr(lmsg): logger.debug('Wrote %s for thanks tracking', filename) -def explode(gitdir, lmsg, mailfrom=None, retrieve_links=True): +def explode(gitdir, lmsg, mailfrom=None, retrieve_links=True, fpopts=None): ecode = fetch_remote(gitdir, lmsg, check_sig=False, ty_track=False) if ecode > 0: sys.exit(ecode) @@ -290,7 +290,7 @@ def explode(gitdir, lmsg, mailfrom=None, retrieve_links=True): # of the archived threads. linked_ids.add(lmsg.msgid) - with b4.git_format_patches(gitdir, lmsg.pr_base_commit, 'FETCH_HEAD', prefixes=prefixes) as pdir: + with b4.git_format_patches(gitdir, lmsg.pr_base_commit, 'FETCH_HEAD', prefixes=prefixes, extraopts=fpopts) as pdir: if pdir is None: sys.exit(1) @@ -374,6 +374,9 @@ def explode(gitdir, lmsg, mailfrom=None, retrieve_links=True): seen_msgids = set() for msgid in linked_ids: + # Did we already retrieve it as part of a previous tread? + if msgid in seen_msgids: + continue savefile = mkstemp()[1] mboxfile = b4.get_pi_thread_by_msgid(msgid, savefile) if mboxfile is not None: -- cgit v1.2.3