change version numbers inside processing function as well

This commit is contained in:
nickfyson 2023-12-15 17:02:32 +00:00
Родитель 8e4a6c7a90
Коммит e0c2b0a8a0
1 изменённых файлов: 5 добавлений и 6 удалений

11
.github/update-release-branch.py поставляемый
Просмотреть файл

@ -175,7 +175,7 @@ def get_today_string():
today = datetime.datetime.today() today = datetime.datetime.today()
return '{:%d %b %Y}'.format(today) return '{:%d %b %Y}'.format(today)
def process_changelog_for_backports(target_version): def process_changelog_for_backports(source_branch_major_version, target_branch_major_version):
# changelog entries use a speficic format to indicate # changelog entries use a speficic format to indicate
# that they only apply to newer versions # that they only apply to newer versions
@ -191,6 +191,7 @@ def process_changelog_for_backports(target_version):
output += line + '\n' output += line + '\n'
if line.startswith('## '): if line.startswith('## '):
line = line.replace(f'## {source_branch_major_version}', f'## {target_branch_major_version}')
# we have found the first section, so now handle things differently # we have found the first section, so now handle things differently
break break
@ -206,10 +207,11 @@ def process_changelog_for_backports(target_version):
# filter out changenote entries that apply only to newer versions # filter out changenote entries that apply only to newer versions
match = regex.search(line) match = regex.search(line)
if match: if match:
if int(target_version) < int(match.group(1)): if int(target_branch_major_version) < int(match.group(1)):
continue continue
if line.startswith('## '): if line.startswith('## '):
line = line.replace(f'## {source_branch_major_version}', f'## {target_branch_major_version}')
if found_content == False: if found_content == False:
# we have found two headings in a row, so we need to add the placeholder message. # we have found two headings in a row, so we need to add the placeholder message.
output += 'No user facing changes.\n' output += 'No user facing changes.\n'
@ -375,10 +377,7 @@ def main():
# Migrate the changelog notes from vLatest version numbers to vOlder version numbers # Migrate the changelog notes from vLatest version numbers to vOlder version numbers
print(f'Migrating changelog notes from v{source_branch_major_version} to v{target_branch_major_version}') print(f'Migrating changelog notes from v{source_branch_major_version} to v{target_branch_major_version}')
subprocess.check_output(['sed', '-i', f's/^## {source_branch_major_version}\./## {target_branch_major_version}./g', 'CHANGELOG.md']) process_changelog_for_backports(source_branch_major_version, target_branch_major_version)
# process changelog for backport to target release branch
process_changelog_for_backports(target_branch_major_version)
# Amend the commit generated by `npm version` to update the CHANGELOG # Amend the commit generated by `npm version` to update the CHANGELOG
run_git('add', 'CHANGELOG.md') run_git('add', 'CHANGELOG.md')