Release tools: Refactor bug fixes per release script to be easier to expand

If a user wants to expand the "bug fixes per release" script with
new classifications, it requires them searching for and expanding a few
lists spread through out the code.

This annoying for anyone not familiar with the code, so refactor these
lists out to the "Constants" section to make it easier to see and
expands.
This commit is contained in:
Alaska
2025-03-04 01:52:59 +13:00
parent f2c7e60a8c
commit 60e4b0e5d0

View File

@@ -186,6 +186,9 @@ FIXED_OLD_ISSUE = "FIXED OLD"
FIXED_PR = "FIXED PR"
REVERT = "REVERT"
SORTED_CLASSIFICATIONS = [FIXED_NEW_ISSUE, FIXED_OLD_ISSUE]
VALID_CLASSIFICATIONS = [FIXED_NEW_ISSUE, NEEDS_MANUAL_SORTING, FIXED_OLD_ISSUE, FIXED_PR, REVERT]
OLDER_VERION = "OLDER"
NEWER_VERION = "NEWER"
SAME_VERION = "SAME"
@@ -329,13 +332,13 @@ class CommitInfo:
# If the fix was back-ported to a old release, then it fixed a old issue.
self.classification = FIXED_OLD_ISSUE
def override_report_info(self, new_classification: str, new_title: str, new_module: str) -> None:
if new_classification in (FIXED_NEW_ISSUE, FIXED_OLD_ISSUE):
def override_report_info(self, new_classification: str, new_title: str, new_module: str) -> bool:
if new_classification in SORTED_CLASSIFICATIONS:
# Clear classifications are more important then any other. So always override in this case.
self.classification = new_classification
self.report_title = new_title
self.module = new_module
return
return True
if new_classification in (NEEDS_MANUAL_SORTING, FIXED_PR):
if (self.classification == UNKNOWN) or ((new_classification ==
@@ -346,7 +349,8 @@ class CommitInfo:
self.classification = new_classification
self.report_title = new_title
self.module = new_module
return
return False
def get_module(self, labels: list[dict[Any, Any]]) -> str:
# Figures out what module the report that was fixed belongs too.
@@ -373,8 +377,6 @@ class CommitInfo:
self.report_title = self.commit_title
return
sorted_classes = (FIXED_NEW_ISSUE, FIXED_OLD_ISSUE)
for report_number in self.fixed_reports:
report_information = url_json_get(
f"https://projects.blender.org/api/v1/repos/blender/blender/issues/{report_number}")
@@ -392,11 +394,9 @@ class CommitInfo:
current_version=current_version,
previous_version=previous_version,
)
self.override_report_info(classification, report_title, module)
if self.classification in sorted_classes:
# The commit has been sorted. No need to process more reports.
break
if self.override_report_info(classification, report_title, module):
# The commit has been sorted. No need to process more reports.
break
def generate_release_note_ready_string(self) -> str:
# Breakup report_title based on words, and remove `:` if it's at the end of the first word.
@@ -708,19 +708,12 @@ def prepare_for_print(list_of_commits: list[CommitInfo]) -> dict[str, dict[str,
# This function takes in a list of commits, and sorts them based on their classification and module.
dict_of_sorted_commits: dict[str, dict[str, list[CommitInfo]]] = {}
valid_classifications = [
FIXED_OLD_ISSUE,
NEEDS_MANUAL_SORTING,
REVERT,
FIXED_PR,
FIXED_NEW_ISSUE,
]
for item in valid_classifications:
for item in VALID_CLASSIFICATIONS:
dict_of_sorted_commits[item] = {}
for commit in list_of_commits:
commit_classification = commit.classification
if commit_classification in valid_classifications:
if commit_classification in VALID_CLASSIFICATIONS:
commit_module = commit.module
try:
# Try to append to a list. If it fails (The list doesn't exist), create the list.
@@ -728,7 +721,7 @@ def prepare_for_print(list_of_commits: list[CommitInfo]) -> dict[str, dict[str,
except KeyError:
dict_of_sorted_commits[commit_classification][commit_module] = [commit]
for item in valid_classifications:
for item in VALID_CLASSIFICATIONS:
# Sort modules alphabetically
dict_of_sorted_commits[item] = dict(sorted(dict_of_sorted_commits[item].items()))