Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy the severity from duplicate bugs #1767

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions auto_nag/scripts/duplicate_copy_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from auto_nag import utils
from auto_nag.bzcleaner import BzCleaner
from auto_nag.severity import Severity


class DuplicateCopyMetadata(BzCleaner):
Expand All @@ -34,6 +35,7 @@ def get_bugs(self, date="today", bug_ids=[], chunk_size=None):
include_fields=[
"id",
"summary",
"severity",
"whiteboard",
"keywords",
"duplicates",
Expand Down Expand Up @@ -80,6 +82,23 @@ def get_bugs(self, date="today", bug_ids=[], chunk_size=None):
elif new_access_tag == copied_fields["whiteboard"]["value"]:
copied_fields["whiteboard"]["from"].append(dup_bug["id"])

# Severity: if it is not set, copy it from duplicates
if (
bug["severity"] == "--"
and dup_bug["severity"] in Severity.SEVERITY_LEVELS
):
new_severity = dup_bug["severity"]
if (
"severity" not in copied_fields
or new_severity < copied_fields["severity"]["value"]
):
copied_fields["severity"] = {
"from": [dup_bug["id"]],
"value": dup_bug["severity"],
}
elif new_severity == copied_fields["severity"]["value"]:
copied_fields["severity"]["from"].append(dup_bug["id"])

if copied_fields:
copied_fields = sorted(
(
Expand Down Expand Up @@ -126,6 +145,8 @@ def set_autofix(self, bug: dict, copied_fields: List[tuple]) -> None:
autofix["keywords"] = {"add": value}
elif field == "whiteboard":
autofix["whiteboard"] = bug["whiteboard"] + value
elif field == "severity":
autofix["severity"] = value
else:
raise ValueError(f"Unsupported field: {field}")

Expand All @@ -140,6 +161,7 @@ def columns(self):

def get_bz_params(self, date):
fields = [
"severity",
"whiteboard",
"keywords",
"dupe_of",
Expand All @@ -152,10 +174,14 @@ def get_bz_params(self, date):
"chfield": [
"resolution",
"keywords",
"bug_severity",
"status_whiteboard",
],
"j1": "OR",
"f1": "OP",
"f2": "bug_severity",
"o2": "anyexact",
"v2": list(Severity.SEVERITY_LEVELS),
"f3": "status_whiteboard",
"o3": "anywordssubstr",
"v3": "[access-s",
Expand Down