Skip to content

Commit 493356f

Browse files
committed
air: try to fetch the subject from lore
Patchwork messes up the subject, see: https://lore.kernel.org/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0d48903 commit 493356f

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

air-email-review.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import argparse
77
import configparser
8+
import email
89
import os
910
import re
1011
import subprocess
@@ -13,6 +14,7 @@
1314
import textwrap
1415
from pathlib import Path
1516
from typing import Dict, List, Optional, Tuple
17+
from urllib.parse import urlparse
1618
import requests
1719

1820

@@ -99,6 +101,36 @@ def get_patchwork_patch(self, patch_id: int) -> Dict:
99101
return response.json()
100102

101103

104+
def fetch_original_subject(session: requests.Session,
105+
archive_url: str) -> Optional[str]:
106+
"""Fetch the original Subject from the email archive.
107+
108+
Patchwork mangles subjects (strips PATCH prefix, reformats tags),
109+
so we fetch the raw email from the archive to get the real Subject.
110+
"""
111+
if not archive_url:
112+
return None
113+
114+
# lore.kernel.org serves raw email when /raw is appended
115+
parsed = urlparse(archive_url)
116+
if parsed.hostname == 'lore.kernel.org':
117+
raw_url = archive_url.rstrip('/') + '/raw'
118+
else:
119+
raw_url = archive_url
120+
121+
try:
122+
response = session.get(raw_url, timeout=30)
123+
response.raise_for_status()
124+
except requests.exceptions.RequestException:
125+
return None
126+
127+
msg = email.message_from_string(response.text)
128+
subject = msg.get('Subject')
129+
if subject:
130+
return subject
131+
return None
132+
133+
102134
def extract_commit_subject(review_text: str) -> str:
103135
"""Extract the commit subject from review text"""
104136
# Look for "commit <hash>\nAuthor: ...\n\n <subject>"
@@ -613,6 +645,12 @@ def main():
613645
patch_info = patch_info_list[i]
614646
message_id = patch_info.get('msgid', '')
615647

648+
# Fetch original subject from archive to avoid Patchwork mangling
649+
archive_url = patch_info.get('list_archive_url')
650+
original_subject = fetch_original_subject(client.session, archive_url)
651+
if original_subject:
652+
patch_info['name'] = original_subject
653+
616654
# Skip empty reviews (None or empty string)
617655
if review_text is None or review_text.strip() == '':
618656
if args.verbose:

0 commit comments

Comments
 (0)