aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-07-16 08:57:02 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-07-16 08:57:02 -0400
commiteef190d827f3a87a23a2fc79f08aa96a147d0fa0 (patch)
treeecef0e2522deeceb64ab0b83e232d2d647da80c6
parent2083cbc7628b59e160da9eeb0133f032bf33dec5 (diff)
downloadb4-eef190d827f3a87a23a2fc79f08aa96a147d0fa0.tar.gz
submit: fix signed-off-by logic in --update-trailers
We weren't quite doing the right thing when --update-trailers was used with --signoff, so this should fix the behaviour and the output. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/submit.py76
1 files changed, 42 insertions, 34 deletions
diff --git a/b4/submit.py b/b4/submit.py
index 0834ff8..9e28d9b 100644
--- a/b4/submit.py
+++ b/b4/submit.py
@@ -332,8 +332,12 @@ def update_trailers(cover_commit: str, cmdargs: argparse.Namespace) -> None:
patchid = b4.LoreMessage.get_patch_id(body)
msg_map[patchid] = msg
commit_map[patchid] = commit
- if signoff and f'{signoff[0]}: <{signoff[1]}>' not in body:
+ parts = b4.LoreMessage.get_body_parts(body)
+ # Force SOB update
+ if signoff and (signoff not in parts[2] or (len(signoff) > 1 and parts[2][-1] != signoff)):
updates[patchid] = list()
+ if signoff not in parts[2]:
+ updates[patchid].append(signoff)
if cmdargs.thread_msgid:
cmdargs.msgid = cmdargs.thread_msgid
@@ -347,38 +351,37 @@ def update_trailers(cover_commit: str, cmdargs: argparse.Namespace) -> None:
query = f'"change-id: {changeid}"'
list_msgs = b4.get_pi_search_results(query, nocache=True)
- bbox = b4.LoreMailbox()
- for list_msg in list_msgs:
- bbox.add_message(list_msg)
-
- lser = bbox.get_series(sloppytrailers=cmdargs.sloppytrailers)
- mismatches = list(lser.trailer_mismatches)
- for lmsg in lser.patches[1:]:
- addtrailers = list(lmsg.followup_trailers)
- if lser.has_cover and len(lser.patches[0].followup_trailers):
- addtrailers += list(lser.patches[0].followup_trailers)
- if not addtrailers:
- logger.debug('No follow-up trailers received to the %s', lmsg.subject)
- continue
- patchid = b4.LoreMessage.get_patch_id(lmsg.body)
- if patchid not in commit_map:
- logger.debug('No match for patchid %s', patchid)
- continue
- parts = b4.LoreMessage.get_body_parts(msg_map[patchid].get_payload())
- if signoff and signoff not in parts[2]:
- updates[patchid] = list()
- for ftrailer in addtrailers:
- if ftrailer[:3] not in parts[2]:
- if patchid not in updates:
- updates[patchid] = list()
- updates[patchid].append(ftrailer)
- # Check if we've applied mismatched trailers already
- if not cmdargs.sloppytrailers and mismatches:
- for mtrailer in list(mismatches):
- check = (mtrailer[0], mtrailer[1], None)
- if check in parts[2]:
- logger.debug('Removing already-applied mismatch %s', check)
- mismatches.remove(mtrailer)
+
+ if list_msgs:
+ bbox = b4.LoreMailbox()
+ for list_msg in list_msgs:
+ bbox.add_message(list_msg)
+
+ lser = bbox.get_series(sloppytrailers=cmdargs.sloppytrailers)
+ mismatches = list(lser.trailer_mismatches)
+ for lmsg in lser.patches[1:]:
+ addtrailers = list(lmsg.followup_trailers)
+ if lser.has_cover and len(lser.patches[0].followup_trailers):
+ addtrailers += list(lser.patches[0].followup_trailers)
+ if not addtrailers:
+ logger.debug('No follow-up trailers received to the %s', lmsg.subject)
+ continue
+ patchid = b4.LoreMessage.get_patch_id(lmsg.body)
+ if patchid not in commit_map:
+ logger.debug('No match for patchid %s', patchid)
+ continue
+ for ftrailer in addtrailers:
+ if ftrailer[:3] not in parts[2]:
+ if patchid not in updates:
+ updates[patchid] = list()
+ updates[patchid].append(ftrailer)
+ # Check if we've applied mismatched trailers already
+ if not cmdargs.sloppytrailers and mismatches:
+ for mtrailer in list(mismatches):
+ check = (mtrailer[0], mtrailer[1], None)
+ if check in parts[2]:
+ logger.debug('Removing already-applied mismatch %s', check)
+ mismatches.remove(mtrailer)
if not updates:
logger.info('No trailer updates found.')
@@ -399,7 +402,12 @@ def update_trailers(cover_commit: str, cmdargs: argparse.Namespace) -> None:
# Make it a LoreMessage, so we can run attestation on received trailers
cmsg = b4.LoreMessage(msg_map[patchid])
logger.info(' %s', cmsg.subject)
- cmsg.followup_trailers = newtrailers
+ if len(newtrailers):
+ cmsg.followup_trailers = newtrailers
+ if signoff in newtrailers:
+ logger.info(' + %s: %s', signoff[0], signoff[1])
+ elif signoff:
+ logger.info(' > %s: %s', signoff[0], signoff[1])
cmsg.fix_trailers(signoff=signoff)
fred.add(commit_map[patchid], cmsg.message)
logger.info('---')