Skip to content

Commit 622e99f

Browse files
carlescufifabiobaltieri
authored andcommitted
action: Consolidate the merge status processing
Instead of having multiple sources of truth for the merge (or DNM) status, use the _get_merge_status() function for both the labeling and the note. Signed-off-by: Carles Cufi <[email protected]>
1 parent b5b9bb5 commit 622e99f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

action.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def manifest_at_rev(sha):
260260

261261
return (old_manifest, new_manifest)
262262

263-
def _get_status_note(len_a, len_r, len_pr, impostor_shas):
263+
def _get_merge_status(len_a, len_r, len_pr, impostor_shas):
264264
strs = []
265265
def plural(count):
266266
return 's' if count > 1 else ''
@@ -275,7 +275,7 @@ def plural(count):
275275
strs.append(f'{impostor_shas} impostor SHA{plural(impostor_shas)}')
276276

277277
if not len(strs):
278-
return '\u2705 **All manifest checks OK**'
278+
return False, '\u2705 **All manifest checks OK**'
279279

280280
n = '\u274c **DNM label due to: '
281281
for i, s in enumerate(strs):
@@ -285,7 +285,7 @@ def plural(count):
285285
_s = f'{s}, ' if (len(strs) - i > 2) else f'{s} '
286286
n += _s
287287
n += '**'
288-
return n
288+
return True, n
289289

290290
def _get_sets(old_projs, new_projs):
291291
# Symmetric difference: everything that is not in both
@@ -493,8 +493,8 @@ def main():
493493
strs.append(line)
494494

495495
# Add a note about the merge status of the manifest PR
496-
status_note = _get_status_note(len(aprojs), len(rprojs), len(pr_projs),
497-
impostor_shas)
496+
dnm, status_note = _get_merge_status(len(aprojs), len(rprojs), len(pr_projs),
497+
impostor_shas)
498498
status_note = f'\n\n{status_note}'
499499

500500
message = '\n'.join(strs) + status_note + NOTE
@@ -554,7 +554,7 @@ def get_relevant_labels(label_list):
554554
log(f'Unable to remove prefixed label {l}')
555555

556556
if dnm_labels:
557-
if not len(rprojs) and not len(aprojs) and not len(pr_projs) and not impostor_shas:
557+
if not dnm:
558558
# Remove the DNM labels
559559
try:
560560
for l in dnm_labels:

0 commit comments

Comments
 (0)