Release note tools: Remove manual sorting of revert commits
In a previous commit (1) a feature was added to the bug fixes per release script that prompted users if they want to sort revert commits. This commit removes this feature, instead preferring that revert commits are sorted in the overrides task (blender/blender#137983) This was done because: - The overrides task allows for greater control over how revert commits are classified, and it's synced between all users. - The prompt to sort the commits appearing each time the script is run is annoying for triagers who may run the script multiple times in one day as they sort through various commits. (1) blender/blender@9679d9a3eb Pull Request: https://projects.blender.org/blender/blender/pulls/138505
This commit is contained in:
@@ -281,11 +281,9 @@ class CommitInfo:
|
||||
__slots__ = (
|
||||
"hash",
|
||||
"commit_title",
|
||||
|
||||
"backport_list",
|
||||
"classification",
|
||||
"fixed_reports",
|
||||
"commit_message",
|
||||
"has_been_overwritten",
|
||||
"is_revert",
|
||||
"module",
|
||||
@@ -306,8 +304,6 @@ class CommitInfo:
|
||||
def set_defaults(self) -> None:
|
||||
self.is_revert = 'revert' in self.commit_title.lower()
|
||||
|
||||
self.commit_message = subprocess.run(
|
||||
['git', 'show', '-s', '--format=%B', self.hash], capture_output=True).stdout.decode('utf-8')
|
||||
self.fixed_reports = self.check_full_commit_message_for_fixed_reports()
|
||||
|
||||
# Setup some "useful" empty defaults.
|
||||
@@ -321,10 +317,13 @@ class CommitInfo:
|
||||
self.has_been_overwritten = False
|
||||
|
||||
def check_full_commit_message_for_fixed_reports(self) -> list[str]:
|
||||
command = ['git', 'show', '-s', '--format=%B', self.hash]
|
||||
command_output = subprocess.run(command, capture_output=True).stdout.decode('utf-8')
|
||||
|
||||
# Find every instance of `SPACE#NUMBER`. These are the report that the commit claims to fix.
|
||||
# We are looking for the `SPACE` part because otherwise commits that fix issues in other repositories,
|
||||
# E.g. Fix `blender/blender-manual#NUMBER`, will be picked out for processing.
|
||||
match = re.findall(r'\s#+(\d+)', self.commit_message)
|
||||
match = re.findall(r'\s#+(\d+)', command_output)
|
||||
if match:
|
||||
return match
|
||||
return []
|
||||
@@ -442,7 +441,6 @@ class CommitInfo:
|
||||
def prepare_for_cache(self) -> tuple[str, dict[str, Any]]:
|
||||
return self.hash, {
|
||||
'is_revert': self.is_revert,
|
||||
'commit_message': self.commit_message,
|
||||
'fixed_reports': self.fixed_reports,
|
||||
'backport_list': self.backport_list,
|
||||
'module': self.module,
|
||||
@@ -452,7 +450,6 @@ class CommitInfo:
|
||||
|
||||
def read_from_cache(self, cache_data: dict[str, Any]) -> None:
|
||||
self.is_revert = cache_data['is_revert']
|
||||
self.commit_message = cache_data['commit_message']
|
||||
self.fixed_reports = cache_data['fixed_reports']
|
||||
self.backport_list = cache_data['backport_list']
|
||||
self.module = cache_data['module']
|
||||
@@ -470,6 +467,8 @@ class CommitInfo:
|
||||
self.fixed_reports = [override_data]
|
||||
self.needs_update = True
|
||||
|
||||
# Revert commits that have been overwritten should be processed like normal commits.
|
||||
self.is_revert = False
|
||||
self.has_been_overwritten = True
|
||||
|
||||
# ---
|
||||
@@ -732,55 +731,6 @@ def classify_commits(
|
||||
print("\n\n\n")
|
||||
|
||||
|
||||
def sort_reverts(list_of_commits: list[CommitInfo]) -> None:
|
||||
number_of_revert_commits = 0
|
||||
for commit in list_of_commits:
|
||||
if commit.classification == REVERT:
|
||||
number_of_revert_commits += 1
|
||||
|
||||
if number_of_revert_commits == 0:
|
||||
# Early out since there are no revert commits to sort
|
||||
return
|
||||
|
||||
while True:
|
||||
sort = input(f"Would you like to sort ({number_of_revert_commits}) reverts? (Y/N) ")
|
||||
|
||||
if sort.lower() == "n":
|
||||
return
|
||||
if sort.lower() == "y":
|
||||
break
|
||||
|
||||
for revert_commit in list_of_commits:
|
||||
if revert_commit.classification == REVERT:
|
||||
# Add some space between each commit message.
|
||||
print("\n" * 10)
|
||||
|
||||
print({revert_commit.commit_message})
|
||||
reverted_commit_list = input(
|
||||
f"Which commit hash(s) did this commit fix? Provide a comma separated list for multiple commits. Leave blank if you do not know: ")
|
||||
|
||||
reverted_commit_hashs: list[str] = []
|
||||
for hash in reverted_commit_list.split(","):
|
||||
# Split the comma separated list and remove any extra white spaces from it.
|
||||
hash = hash.strip()
|
||||
if len(hash) != 0:
|
||||
reverted_commit_hashs.append(hash)
|
||||
|
||||
if len(reverted_commit_hashs) == 0:
|
||||
# A commit hash wasn't provided.
|
||||
continue
|
||||
|
||||
# This is just to shift the commit into a list we don't share in the release notes.
|
||||
# An alternative classification is `IGNORED` but then the information won't be saved to the cache.
|
||||
revert_commit.classification = FIXED_NEW_ISSUE
|
||||
|
||||
for hash in reverted_commit_hashs:
|
||||
for commit in list_of_commits:
|
||||
if commit.hash.startswith(hash):
|
||||
# This is just to shift the commit out of the list of `FIXED_OLD_ISSUE`.
|
||||
commit.classification = FIXED_NEW_ISSUE
|
||||
|
||||
|
||||
# ---
|
||||
|
||||
def prepare_for_print(list_of_commits: list[CommitInfo]) -> dict[str, dict[str, list[CommitInfo]]]:
|
||||
@@ -843,7 +793,9 @@ def print_release_notes(list_of_commits: list[CommitInfo]) -> None:
|
||||
|
||||
print_list_of_commits("Commits that fixed old issues:", dict_of_sorted_commits[FIXED_OLD_ISSUE])
|
||||
|
||||
print_list_of_commits("Revert commits:", dict_of_sorted_commits[REVERT])
|
||||
print_list_of_commits(
|
||||
"Revert commits. Add overrides to https://projects.blender.org/blender/blender/issues/137983:",
|
||||
dict_of_sorted_commits[REVERT])
|
||||
|
||||
print_list_of_commits("Commits that need manual sorting:", dict_of_sorted_commits[NEEDS_MANUAL_SORTING])
|
||||
|
||||
@@ -867,9 +819,8 @@ def print_release_notes(list_of_commits: list[CommitInfo]) -> None:
|
||||
`<!-- skip_for_bug_fix_release_notes -->` to the report body and the script will ignore it on subsequent runs.
|
||||
- This should be done by the triaging module through out the release cycle, so the list should be quite small.
|
||||
|
||||
- Go through the "Revert commits" section and if needed,
|
||||
find the commit they reverted and remove them from the list of "Commits that fixed old issues"
|
||||
(This can be done manually or with the overrides feature).
|
||||
- Go through the "Revert commits" section and add entries to https://projects.blender.org/blender/blender/issues/137983
|
||||
for the reverted commits.
|
||||
- Double check if there are any obvious commits in the
|
||||
"Commits that fixed old issues" section that shouldn't be there and remove them
|
||||
(E.g. A fix for a feature that has been in development over a few releases,
|
||||
@@ -1107,8 +1058,6 @@ def main() -> int:
|
||||
previous_version=args.previous_version,
|
||||
)
|
||||
|
||||
sort_reverts(list_of_commits)
|
||||
|
||||
if args.cache:
|
||||
cached_commits_store(list_of_commits)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user