Update status label when reopening a report based on closed status #6

Open
Alaska wants to merge 3 commits from Alaska/blender-bot:reset-to-previous into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit cd01e96e82 - Show all commits

View File

@ -25,7 +25,8 @@ def issues_event(data):
issue_labels = issue["labels"] issue_labels = issue["labels"]
# Ensure valid status on issue close/open. # 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/" status_prefix = "Status/"
type_prefix = "Type/" type_prefix = "Type/"
@ -39,31 +40,20 @@ def issues_event(data):
else: else:
new_status = "Status/Resolved" new_status = "Status/Resolved"
elif action == "reopened": elif action == "reopened":
for label in issue_labels: # Reopen as "Needs Triage" unless the issue was "Resolved"
if label["name"].startswith(status_prefix) and label["name"] not in status_closed: # Reopening a issue after it had been set to "Resolved" means a commit
return # attempted to fix it, but didn't actually fix it and people are still
# experiencing the issue.
# Use Needs Triage as a default
new_status = "Status/Needs Triage" new_status = "Status/Needs Triage"
for label in issue_labels:
issue_timeline = utils.gitea_api_get(issue_url + "/timeline") if label["name"].startswith(status_prefix)
for event in issue_timeline: if label["name"] not in status_closed:
if not event["type"] == "label": # Issue was reopened and had a new status label set.
# We are only interested in events that modify labels # So skip setting a new one.
continue return
if not event["body"] == "1": if label["name"] == status_resolved:
# "body" = "1" denotes that the label was added. new_status = "Status/Confirmed"
# And we don't care about labels that were removed. break
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: else:
return return