Skip to content

Commit 2b6c5c6

Browse files
committed
air: add the ability to inject short message from the CLI
I often find myself editing the email just to say that I actually have not read the review but want to send it out since the author must respin, anyway. Add --say to make those edits quicker. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9df27bc commit 2b6c5c6

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

air-email-review.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import subprocess
1111
import sys
1212
import tempfile
13+
import textwrap
1314
from pathlib import Path
1415
from typing import Dict, List, Optional, Tuple
1516
import requests
@@ -146,7 +147,8 @@ def format_email(review_text: str, patch_info: Dict, from_addr: str,
146147
to_addrs: List[str], cc_addrs: List[str],
147148
header: Optional[str] = None,
148149
footer: Optional[str] = None,
149-
pw_bot: Optional[str] = None) -> str:
150+
pw_bot: Optional[str] = None,
151+
say: Optional[str] = None) -> str:
150152
"""Format review as an email message"""
151153
# Extract subject from the patch
152154
original_subject = patch_info.get('name', 'patch')
@@ -158,10 +160,13 @@ def format_email(review_text: str, patch_info: Dict, from_addr: str,
158160
subject = f"Re: {original_subject}"
159161

160162
# Build email body
161-
body_lines = [
162-
"This is an AI-generated review of your patch. The human sending this",
163-
"email has considered the AI review valid, or at least plausible.",
164-
]
163+
if say:
164+
say = f'says "{say}"'
165+
else:
166+
say = 'has considered the AI review valid, or at least plausible.'
167+
168+
intro = f'This is an AI-generated review of your patch. The human sending this email {say}'
169+
body_lines = textwrap.wrap(intro, width=68)
165170

166171
# Add optional header lines after the intro (interpret \n as newlines)
167172
if header:
@@ -440,6 +445,8 @@ def main():
440445
help='Footer text to add to emails (added after "-- " separator)')
441446
parser.add_argument('--header',
442447
help='Header text to add after the intro line')
448+
parser.add_argument('--say',
449+
help='Override the default "considered the AI review valid" text with custom message')
443450
parser.add_argument('--to', action='append', dest='extra_to', default=[],
444451
help='Additional To addresses (can be repeated)')
445452
parser.add_argument('--cc', action='append', dest='extra_cc', default=[],
@@ -477,6 +484,8 @@ def main():
477484
args.footer = config.get('air-email-review', 'footer')
478485
if args.header is None and config.has_option('air-email-review', 'header'):
479486
args.header = config.get('air-email-review', 'header')
487+
if args.say is None and config.has_option('air-email-review', 'say'):
488+
args.say = config.get('air-email-review', 'say')
480489

481490
if config.has_section('patchwork'):
482491
if args.patchwork_url is None and config.has_option('patchwork', 'url'):
@@ -493,6 +502,8 @@ def main():
493502
args.footer = None
494503
if args.header == '':
495504
args.header = None
505+
if args.say == '':
506+
args.say = None
496507

497508
# Check required settings
498509
if not args.air_url:
@@ -613,7 +624,7 @@ def main():
613624
pw_bot_arg = args.pw_bot if not first_email_sent else None
614625
email_content = format_email(
615626
review_text, patch_info, args.from_addr, to_addrs, cc_addrs,
616-
args.header, args.footer, pw_bot_arg
627+
args.header, args.footer, pw_bot_arg, args.say
617628
)
618629
first_email_sent = True
619630

0 commit comments

Comments
 (0)