b4: ty: Fix incorrect patch/commit association
cover b4: ty: Fix incorrect patch/commit association
From: Will Deacon <[email protected]>
Hi folks,
I recently ran into an issue where 'b4 ty' generated an incorrect list of commit IDs in the "thank you" letter. I've had a crack at fixing it and the details are in patch 1. Patch 2 is drive-by cleanup while I was there.
Please have a look!
Cheers,
Will
Will Deacon (2):
ty: Try subject matching for every commit before using trackers
ty: Remove unused 'matches' variable
src/b4/ty.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
PATCH 1/2 ty: Try subject matching for every commit before using trackers
From: Will Deacon <[email protected]>
Nicolin reports that 'b4 ty' produced a "thank you" letter with incorrect commit IDs:
https://lore.kernel.org/r/ZeDtfKMUXnOnJOic@Asurada-Nvidia
This appears to be because of the creative use of Message-Ids in the series at:
https://lore.kernel.org/r/[email protected]
For example, comparing the Message-Id of patches 1 and 11 of that series, we can see that one is a substring of the other:
Message-Id: <[email protected]>
Message-Id: <[email protected]>
This confuses auto_locate_series(), as it will end up matching the Message-Id of patch 1 with the Link: tag in patch 11 and therefore get the wrong patch/commit association.
Fix this problem by trying to match each commit based on the Subject before falling back to the fuzzier tracker-based matching.
--- src/b4/ty.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
src/b4/ty.py +7 -1
@@ -217,7 +217,13 @@ def auto_locate_series(gitdir: Optional[str], jsondata: dict, branch: str, success = True matches += 1 break - elif len(patch) > 2 and len(patch[2]) and len(commit[2]): + + if success: + continue + + # try to locate by tracker + for pwhash, commit in commits.items(): + if len(patch) > 2 and len(patch[2]) and len(commit[2]): for tracker in commit[2]: if tracker.find(patch[2]) >= 0: logger.debug('Matched using recorded message-id')
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
PATCH 2/2 ty: Remove unused 'matches' variable
In reply to Will DeaconFrom: Will Deacon <[email protected]>
The 'matches' variable in auto_locate_series() is updated but not used for anything, so remove it.
--- src/b4/ty.py | 4 ---- 1 file changed, 4 deletions(-)
src/b4/ty.py +0 -4
@@ -198,7 +198,6 @@ def auto_locate_series(gitdir: Optional[str], jsondata: dict, branch: str, patchids = set(commits.keys()) # We need to find all of them in the commits found = list() - matches = 0 at = 0 for patch in jsondata['patches']: at += 1
@@ -206,7 +205,6 @@ def auto_locate_series(gitdir: Optional[str], jsondata: dict, branch: str, if patch[1] in patchids: logger.debug('Found: %s', patch[0]) found.append((at, commits[patch[1]][0])) - matches += 1 else: # try to locate by subject success = False
@@ -215,7 +213,6 @@ def auto_locate_series(gitdir: Optional[str], jsondata: dict, branch: str, logger.debug('Matched using subject') found.append((at, commit[0])) success = True - matches += 1 break if success:
@@ -229,7 +226,6 @@ def auto_locate_series(gitdir: Optional[str], jsondata: dict, branch: str, logger.debug('Matched using recorded message-id') found.append((at, commit[0])) success = True - matches += 1 break if success: break
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
Quoted 1 line · Will Deacon
From: Will Deacon <[email protected]>
Sorry, I forgot to configure my .git/config properly so it's got the wrong author email address for these patches.
I won't resend immediately just for that, but I can send an updated v2 next week assuming these patches look like the right sort of idea.
Cheers,
Will