Skip to content

Commit e0552b7

Browse files
committed
Added exceptions parameter to changelog verification with exception of current editor bump
1 parent fc03ea0 commit e0552b7

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

Tools/scripts/Utils/verifyReleaseConditions.py

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@ def is_release_date(weekday, release_week_cycle, anchor_date):
4040
return weeks_since_anchor % release_week_cycle == 0
4141

4242

43-
def is_changelog_empty(changelog_path):
43+
# Note that exceptions parameter can include changelog entries that are not considered "meaningful".
44+
# That means that if Changelog consists ONLY of these entries, it is still considered empty.
45+
def is_changelog_empty(changelog_path, exceptions=None):
4446
"""
4547
Checks if the [Unreleased] section in the CHANGELOG.md contains meaningful entries.
4648
It is considered "empty" if the section only contains headers (like ### Added) but no actual content.
4749
"""
50+
51+
if exceptions is None:
52+
exceptions = []
53+
4854
if not os.path.exists(changelog_path):
4955
raise FileNotFoundError(f"Changelog file not found at {changelog_path}")
5056

@@ -55,11 +61,28 @@ def is_changelog_empty(changelog_path):
5561
# Then it matches in the first group all empty sections (only lines that are empty or start with ##)
5662
# The second group matches the start of the next Changelog entry (## [).
5763
# if both groups are matched it means that the Unreleased section is empty.
58-
pattern = re.compile(r"^## \[Unreleased\]\n((?:^###.*\n|^\s*\n)*)(^## \[)", re.MULTILINE)
59-
match = pattern.search(content)
60-
61-
# If we find a match for the "empty unreleased changelog entry" pattern, it means the changelog IS empty.
62-
return match
64+
unreleased_match = re.search(r"^## \[Unreleased\][ \t]*\n((?:.*\n)*?)(?=^## \[)", content, re.MULTILINE)
65+
66+
if not unreleased_match:
67+
print("Could not find [Unreleased] section in the changelog.")
68+
return True # No [Unreleased] section found, treat as empty
69+
70+
unreleased_content = unreleased_match.group(1)
71+
# Split into lines and filter out headers and empty lines
72+
entries = [line.strip() for line in unreleased_content.splitlines()
73+
if line.strip() and not line.strip().startswith("###")]
74+
75+
# If no entries, changelog is empty
76+
if not entries:
77+
print("The [Unreleased] section in the changelog is empty.")
78+
return True
79+
80+
# If all entries are in exceptions, changelog is empty
81+
if all(entry in exceptions for entry in entries):
82+
print("The [Unreleased] section in the changelog has no meaningful entries (only exceptions).")
83+
return True
84+
85+
return False
6386

6487

6588
def verifyReleaseConditions(config: ReleaseConfig):
@@ -72,12 +95,15 @@ def verifyReleaseConditions(config: ReleaseConfig):
7295
"""
7396

7497
error_messages = []
98+
exceptions = [
99+
"* Changed minimum Unity version supported to 2022.3 LTS"
100+
]
75101

76102
try:
77103
if not is_release_date(config.release_weekday, config.release_week_cycle, config.anchor_date):
78104
error_messages.append(f"Condition not met: Today is not the scheduled release day. It should be weekday: {config.release_weekday}, every {config.release_week_cycle} weeks starting from {config.anchor_date}.")
79105

80-
if is_changelog_empty(config.changelog_path):
106+
if is_changelog_empty(config.changelog_path, exceptions):
81107
error_messages.append("Condition not met: The [Unreleased] section of the changelog has no meaningful entries.")
82108

83109
if config.github_manager.is_branch_present(config.release_branch_name):

0 commit comments

Comments
 (0)