From 72ba8d6cd50752bc1e91ae1b7c9b2c82ff5c4939 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Mon, 20 Jan 2025 19:16:11 +0530 Subject: [PATCH] feat: remove obsolete labels in closed/merged PRs --- openedx_webhooks/labels.py | 21 +++++++++++++++++++++ openedx_webhooks/tasks/pr_tracking.py | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/openedx_webhooks/labels.py b/openedx_webhooks/labels.py index e5a53ac8..4792de54 100644 --- a/openedx_webhooks/labels.py +++ b/openedx_webhooks/labels.py @@ -14,3 +14,24 @@ "blended", "open-source-contribution", } + +GITHUB_MERGED_PR_OBSOLETE_LABELS = { + "blocked by other work", + "changes requested", + "inactive", + "needs maintainer attention", + "needs more product information", + "needs rescoping", + "needs reviewer assigned", + "needs test run", + "waiting for eng review", + "waiting on author", +} + +GITHUB_CLOSED_PR_OBSOLETE_LABELS = { + "needs maintainer attention", + "needs reviewer assigned", + "needs test run", + "waiting for eng review", + "waiting on author", +} diff --git a/openedx_webhooks/tasks/pr_tracking.py b/openedx_webhooks/tasks/pr_tracking.py index bc8f579b..8927410c 100644 --- a/openedx_webhooks/tasks/pr_tracking.py +++ b/openedx_webhooks/tasks/pr_tracking.py @@ -59,6 +59,8 @@ ) from openedx_webhooks.labels import ( GITHUB_CATEGORY_LABELS, + GITHUB_CLOSED_PR_OBSOLETE_LABELS, + GITHUB_MERGED_PR_OBSOLETE_LABELS, GITHUB_STATUS_LABELS, ) from openedx_webhooks import settings @@ -477,6 +479,10 @@ def _fix_github_labels(self) -> None: """ desired_labels = set(self.desired.github_labels) ad_hoc_labels = self.current.github_labels - GITHUB_CATEGORY_LABELS - GITHUB_STATUS_LABELS + if self.pr["state"] == "closed": + ad_hoc_labels -= GITHUB_CLOSED_PR_OBSOLETE_LABELS + elif self.pr["state"] == "merged": + ad_hoc_labels -= GITHUB_MERGED_PR_OBSOLETE_LABELS desired_labels.update(ad_hoc_labels) if desired_labels != self.current.github_labels: