aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-23 13:31:07 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-23 13:31:07 -0400
commita17dd19c0426b37de2262b50bfba4761b863a6d6 (patch)
treeacda242de357eee347fc86ae552c7a2d40290b3b
parent7b8cd8047d3c17b08ad888e5bf525bdcb9cc6bbd (diff)
downloadb4-a17dd19c0426b37de2262b50bfba4761b863a6d6.tar.gz
ez: move the RESEND prefix into --resend switch
For UX reasons, make --resend a separate switch instead of operating on the --prefixes RESEND logic. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py25
-rw-r--r--b4/command.py6
-rw-r--r--b4/ez.py25
3 files changed, 33 insertions, 23 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index 4e005af..4296b10 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -916,8 +916,8 @@ class LoreMessage:
if self.date.tzinfo is None:
self.date = self.date.replace(tzinfo=datetime.timezone.utc)
- diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', re.M | re.I)
- diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', re.M | re.I)
+ diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', flags=re.M | re.I)
+ diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', flags=re.M | re.I)
# walk until we find the first text/plain part
mcharset = self.msg.get_content_charset()
@@ -2954,16 +2954,17 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[
}
ses = get_requests_session()
res = ses.post(endpoint, json=req)
- if res.status_code == 200:
- try:
- rdata = res.json()
- if rdata.get('result') == 'success':
- return len(tosend)
- except Exception as ex: # noqa
- logger.critical('Odd response from the endpoint: %s', res.text)
-
- logger.critical('500 response from the endpoint: %s', res.text)
- return None
+ try:
+ rdata = res.json()
+ if rdata.get('result') == 'success':
+ return len(tosend)
+ except Exception as ex: # noqa
+ logger.critical('Odd response from the endpoint: %s', res.text)
+ return 0
+
+ if rdata.get('result') == 'error':
+ logger.critical('Error from endpoint: %s', rdata.get('message'))
+ return 0
if smtp:
sent = 0
diff --git a/b4/command.py b/b4/command.py
index af2ce65..1678d45 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -290,14 +290,16 @@ def cmd():
help='Do not send, just dump out raw smtp messages to the stdout')
sp_send.add_argument('-o', '--output-dir',
help='Do not send, write raw messages to this directory (forces --dry-run)')
- sp_send.add_argument('--prefixes', nargs='+', choices=['RFC', 'WIP', 'RESEND'],
- help='Prefixes to add to PATCH (e.g. RFC, WIP, RESEND)')
+ sp_send.add_argument('--prefixes', nargs='+',
+ help='Prefixes to add to PATCH (e.g. RFC, WIP)')
sp_send.add_argument('--no-auto-to-cc', action='store_true', default=False,
help='Do not automatically collect To: and Cc: addresses')
sp_send.add_argument('--to', nargs='+', help='Addresses to add to the To: list')
sp_send.add_argument('--cc', nargs='+', help='Addresses to add to the Cc: list')
sp_send.add_argument('--not-me-too', action='store_true', default=False,
help='Remove yourself from the To: or Cc: list')
+ sp_send.add_argument('--resend', action='store_true', default=False,
+ help='This is a resend of a previously sent series')
sp_send.add_argument('--no-sign', action='store_true', default=False,
help='Do not cryptographically sign your patches with patatt')
ag_sendh = sp_send.add_argument_group('Web submission', 'Authenticate with the web submission endpoint')
diff --git a/b4/ez.py b/b4/ez.py
index 4b7e148..280eb0d 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -821,7 +821,7 @@ def print_pretty_addrs(addrs: list, hdrname: str) -> None:
logger.info(' %s', b4.format_addrs([addr]))
-def get_prep_branch_as_patches(prefixes: Optional[list] = None,
+def get_prep_branch_as_patches(prefixes: Optional[List[str]] = None,
movefrom: bool = True,
thread: bool = True) -> List[Tuple[str, email.message.Message]]:
cover, tracking = load_cover(strip_comments=True)
@@ -937,6 +937,12 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
parts = b4.LoreMessage.get_body_parts(cover)
trailers.update(parts[2])
+ prefixes = cmdargs.prefixes
+ if cmdargs.prefixes is None:
+ prefixes = list()
+ if cmdargs.resend:
+ prefixes.append('RESEND')
+
try:
patches = get_prep_branch_as_patches(prefixes=cmdargs.prefixes)
except RuntimeError as ex:
@@ -1121,13 +1127,18 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
if cmdargs.dryrun:
logger.info('DRYRUN: Would have sent %s messages', len(send_msgs))
return
- else:
- logger.info('Sent %s messages', sent)
+ if not sent:
+ logger.critical('CRITICAL: Was not able to send messages.')
+ sys.exit(1)
+
+ logger.info('Sent %s messages', sent)
+
+ if cmdargs.resend:
+ logger.debug('Not updating cover/tracking on resend')
+ return
- # TODO: need to make the reroll process smoother
mybranch = b4.git_get_current_branch()
revision = tracking['series']['revision']
-
try:
strategy = get_cover_strategy()
if strategy == 'commit':
@@ -1195,10 +1206,6 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
if vrev not in tracking['series']['history']:
tracking['series']['history'][vrev] = list()
tracking['series']['history'][vrev].append(cover_msgid)
- if cmdargs.prefixes and 'RESEND' in cmdargs.prefixes:
- logger.info('Not incrementing current revision due to RESEND')
- store_cover(cover, tracking)
- return
oldrev = tracking['series']['revision']
newrev = oldrev + 1