Skip to content

Commit

Permalink
action: Add DNM when projects are removed
Browse files Browse the repository at this point in the history
Whenever removing a project, add the DNM labels.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
  • Loading branch information
carlescufi committed Oct 29, 2024
1 parent a393354 commit 670a0c4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ def manifest_at_rev(sha):

return (old_manifest, new_manifest)

def _get_status_note(len_a, len_pr, impostor_shas):
def _get_status_note(len_a, len_r, len_pr, impostor_shas):
strs = []
def plural(count):
return 's' if count > 1 else ''

if len_a:
strs.append(f'{len_a} added project{plural(len_a)}')
elif len_r:
strs.append(f'{len_r} removed project{plural(len_r)}')
if len_pr:
strs.append(f'{len_pr} project{plural(len_pr)} with PR revision')
if impostor_shas:
Expand Down Expand Up @@ -475,7 +477,8 @@ def main():
strs.append(line)

# Add a note about the merge status of the manifest PR
status_note = _get_status_note(len(aprojs), len(pr_projs), impostor_shas)
status_note = _get_status_note(len(aprojs), len(rprojs), len(pr_projs),
impostor_shas)
status_note = f'\n\n{status_note}'

message = '\n'.join(strs) + status_note + NOTE
Expand Down Expand Up @@ -535,7 +538,7 @@ def get_relevant_labels(label_list):
log(f'Unable to remove prefixed label {l}')

if dnm_labels:
if not len(aprojs) and not len(pr_projs) and not impostor_shas:
if not len(rprojs) and not len(aprojs) and not len(pr_projs) and not impostor_shas:
# Remove the DNM labels
try:
for l in dnm_labels:
Expand Down

0 comments on commit 670a0c4

Please sign in to comment.