From d03cffc7f162ffb7c3843a9b65480f9428eed222 Mon Sep 17 00:00:00 2001 From: Alaska Date: Fri, 16 Aug 2024 15:16:15 +1200 Subject: [PATCH 1/3] Restore status labels to what they were before they were closed --- labels.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/labels.py b/labels.py index 949dea0..cda98a5 100644 --- a/labels.py +++ b/labels.py @@ -43,8 +43,23 @@ def issues_event(data): if label["name"].startswith(status_prefix) and label["name"] not in status_closed: return - # Set to Needs Triage + # Use Needs Triage as a default new_status = "Status/Needs Triage" + + issue_timeline = utils.gitea_api_get(issue_url + "/timeline") + for event in issue_timeline: + if not event["type"] == "label": + # We are only interested in events that modify labels + continue + old_label_name = event["label"]["name"] + if not old_label_name.startswith(status_prefix): + # We are only interested in label events that modify `Status/` labels + continue + if old_label_name in status_closed: + # We are restoring the report to a open state, so we don't care about + # "closed" labels. + continue + new_status = old_label_name else: return -- 2.30.2 From 562593ed268673d7e0adb7a13561a854bf650eb0 Mon Sep 17 00:00:00 2001 From: Alaska Date: Fri, 16 Aug 2024 15:35:55 +1200 Subject: [PATCH 2/3] Be able to tell the difference between adding and removing labels --- labels.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/labels.py b/labels.py index cda98a5..fced47f 100644 --- a/labels.py +++ b/labels.py @@ -51,6 +51,10 @@ def issues_event(data): if not event["type"] == "label": # We are only interested in events that modify labels continue + if not event["body"] == "1": + # "body" = "1" denotes that the label was added. + # And we don't care about labels that were removed. + continue old_label_name = event["label"]["name"] if not old_label_name.startswith(status_prefix): # We are only interested in label events that modify `Status/` labels -- 2.30.2 From cd01e96e82efed72f03c5780f91b7b67a79a6f17 Mon Sep 17 00:00:00 2001 From: Alaska Date: Fri, 23 Aug 2024 12:52:52 +0200 Subject: [PATCH 3/3] Update labels upon reopening based on feedback from Triaging meeting If a issue is reopened, one of these things will happen: - If a user reopens the report and sets a status label (E.g. Sets "Needs information from...), then the Blender bot will ignore the reopening and won't change the labels. - If a user reopens a report that had the "Resolved" label set, then Blender bot will reset the label to "Confirmed" - Otherwise the label is set to "Needs Triage" --- labels.py | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/labels.py b/labels.py index fced47f..c4e3b51 100644 --- a/labels.py +++ b/labels.py @@ -25,7 +25,8 @@ def issues_event(data): issue_labels = issue["labels"] # Ensure valid status on issue close/open. - status_closed = {"Status/Archived", "Status/Resolved", "Status/Duplicate"} + status_resolved = "Status/Resolved" + status_closed = {"Status/Archived", "Status/Duplicate", status_resolved} status_prefix = "Status/" type_prefix = "Type/" @@ -39,31 +40,20 @@ def issues_event(data): else: new_status = "Status/Resolved" elif action == "reopened": - for label in issue_labels: - if label["name"].startswith(status_prefix) and label["name"] not in status_closed: - return - - # Use Needs Triage as a default + # Reopen as "Needs Triage" unless the issue was "Resolved" + # Reopening a issue after it had been set to "Resolved" means a commit + # attempted to fix it, but didn't actually fix it and people are still + # experiencing the issue. new_status = "Status/Needs Triage" - - issue_timeline = utils.gitea_api_get(issue_url + "/timeline") - for event in issue_timeline: - if not event["type"] == "label": - # We are only interested in events that modify labels - continue - if not event["body"] == "1": - # "body" = "1" denotes that the label was added. - # And we don't care about labels that were removed. - continue - old_label_name = event["label"]["name"] - if not old_label_name.startswith(status_prefix): - # We are only interested in label events that modify `Status/` labels - continue - if old_label_name in status_closed: - # We are restoring the report to a open state, so we don't care about - # "closed" labels. - continue - new_status = old_label_name + for label in issue_labels: + if label["name"].startswith(status_prefix) + if label["name"] not in status_closed: + # Issue was reopened and had a new status label set. + # So skip setting a new one. + return + if label["name"] == status_resolved: + new_status = "Status/Confirmed" + break else: return -- 2.30.2