diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-09-16 12:52:34 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-09-16 12:52:34 -0400 |
commit | c07e23d39cbc8899c1adeac62aec637d42490a7e (patch) | |
tree | 08082b6bb7a4d6ad2b5d17a8e48cdf2b15f9f9b5 | |
parent | d8d415a7fe722cad8c433c2c88e1063c4e491b05 (diff) | |
download | b4-c07e23d39cbc8899c1adeac62aec637d42490a7e.tar.gz |
trailers: add a trailers-ignore-from config option
With bots frequently responding to patch submissions and providing a
suggested trailer to include *once the problem is fixed*, give folks an
option to ignore any trailers from certain email addresses via the
trailers-ignore-from config setting.
Suggested-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://msgid.link/20220916163101.2ij6uznmymqvgklt@ldmartin-desk2.lan
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 17 | ||||
-rw-r--r-- | docs/config.rst | 12 | ||||
-rw-r--r-- | tests/samples/trailers-followup-custody-ref-with-ignored.txt | 40 | ||||
-rw-r--r-- | tests/test___init__.py | 2 |
4 files changed, 68 insertions, 3 deletions
diff --git a/b4/__init__.py b/b4/__init__.py index c773326..760f4aa 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1732,8 +1732,21 @@ class LoreMessage: attpolicy = config['attestation-policy'] fixtrailers = btrailers + # load trailers we should ignore + ignore_from = config.get('trailers-ignore-from') + if ignore_from: + ignores = [x[1].lower() for x in email.utils.getaddresses([ignore_from])] + else: + ignores = list() + + ignored = set() for ltr in new_trailers: - if ltr in fixtrailers: + if ltr in fixtrailers or ltr in ignored: + continue + + if ltr.addr and ltr.addr[1].lower() in ignores: + logger.info(' x %s', ltr.as_string(omit_extinfo=True)) + ignored.add(ltr) continue fixtrailers.append(ltr) @@ -2250,7 +2263,7 @@ def get_main_config() -> dict: # some options can be provided via the toplevel .b4-config file, # so load them up and use as defaults topdir = git_get_toplevel() - wtglobs = ['send-*', '*mask', '*template*'] + wtglobs = ['send-*', '*mask', '*template*', 'trailer*'] if topdir: wtcfg = os.path.join(topdir, '.b4-config') if os.access(wtcfg, os.R_OK): diff --git a/docs/config.rst b/docs/config.rst index 68e0dd4..520ed0e 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -112,6 +112,17 @@ These options control many of the core features of b4. Default: ``*`` +``b4.trailers-ignore-from`` (v0.10+) + A comma-separated list of addresses that should never be considered + for follow-up trailers. This is useful when dealing with reports + generated by automated bots that may insert trailer suggestions, such + as the "kernel test robot." E.g.:: + + [b4] + trailers-ignore-from = lkp@intel.com, someotherbot@example.org + + Default: ``None`` + ``b4.cache-expire`` B4 will cache retrieved threads by default, and this allows tweaking the time (in minutes) before cache is invalidated. Many commands also @@ -222,7 +233,6 @@ These settings control the behaviour of ``b4 ty`` command. Default: ``None`` - ``b4.thanks-commit-url-mask`` Used when creating summaries for ``b4 ty``, and can be set to a value like:: diff --git a/tests/samples/trailers-followup-custody-ref-with-ignored.txt b/tests/samples/trailers-followup-custody-ref-with-ignored.txt new file mode 100644 index 0000000..0582ea9 --- /dev/null +++ b/tests/samples/trailers-followup-custody-ref-with-ignored.txt @@ -0,0 +1,40 @@ +From git@z Thu Jan 1 00:00:00 1970 +Subject: [PATCH] Simple test +From: Test Test <test@example.com> +Date: Tue, 30 Aug 2022 11:19:07 -0400 +Message-Id: <orig-message@example.com> +To: Some List <list-1@lists.example.com> +Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 7bit + +Follow-up trailer collating test. + +Link: https://msgid.link/some@msgid.here +Reviewed-by: Original Reviewer <original-reviewer@example.com> +Signed-off-by: Original Submitter <original-submitter@example.com> +Suggested-by: Friendly Suggester <suggested-by@example.com> +Fixes: abcdef01234567890 +Link: https://lore.kernel.org/some@msgid.here # bug discussion +Tested-by: Followup Reviewer2 <followup-reviewer2@example.com> +Cc: Dev Eloper1 <dev-eloper1@example.com> +Cc: Dev Eloper2 <dev-eloper2@example.com> +Cc: Some List <list-1@lists.example.com> +Signed-off-by: Test Override <test-override@example.com> +--- + +diff --git a/b4/junk.py b/b4/junk.py +index 12345678..23456789 100644 +--- a/b4/junk.py +--- b/b4/junk.py +@@@ -1,1 +1,1 @@ def junk(): + + +-junk1 ++junk2 + + +-- +2.wong.fu + diff --git a/tests/test___init__.py b/tests/test___init__.py index 4beeb91..e666739 100644 --- a/tests/test___init__.py +++ b/tests/test___init__.py @@ -92,6 +92,8 @@ def test_parse_trailers(source, expected): ('custody', {}, {'addmysob': True, 'copyccs': True}, 'unordered', {}), ('custody', {}, {'addmysob': True, 'copyccs': True}, 'ordered', {'trailer-order': 'Cc,Fixes*,Link*,Suggested*,Reviewed*,Tested*,*'}), + ('custody', {}, {'addmysob': True, 'copyccs': True}, 'with-ignored', + {'trailers-ignore-from': 'followup-reviewer1@example.com'}), ('partial-reroll', {}, {'addmysob': True}, 'defaults', {}), ]) def test_followup_trailers(source, serargs, amargs, reference, b4cfg): |