@@ -175,7 +175,7 @@ def get_today_string():
175175 today = datetime .datetime .today ()
176176 return '{:%d %b %Y}' .format (today )
177177
178- def process_changelog_for_backports (target_version ):
178+ def process_changelog_for_backports (source_branch_major_version , target_branch_major_version ):
179179
180180 # changelog entries use a speficic format to indicate
181181 # that they only apply to newer versions
@@ -191,6 +191,7 @@ def process_changelog_for_backports(target_version):
191191
192192 output += line + '\n '
193193 if line .startswith ('## ' ):
194+ line = line .replace (f'## { source_branch_major_version } ' , f'## { target_branch_major_version } ' )
194195 # we have found the first section, so now handle things differently
195196 break
196197
@@ -206,10 +207,11 @@ def process_changelog_for_backports(target_version):
206207 # filter out changenote entries that apply only to newer versions
207208 match = regex .search (line )
208209 if match :
209- if int (target_version ) < int (match .group (1 )):
210+ if int (target_branch_major_version ) < int (match .group (1 )):
210211 continue
211212
212213 if line .startswith ('## ' ):
214+ line = line .replace (f'## { source_branch_major_version } ' , f'## { target_branch_major_version } ' )
213215 if found_content == False :
214216 # we have found two headings in a row, so we need to add the placeholder message.
215217 output += 'No user facing changes.\n '
@@ -375,10 +377,7 @@ def main():
375377
376378 # Migrate the changelog notes from vLatest version numbers to vOlder version numbers
377379 print (f'Migrating changelog notes from v{ source_branch_major_version } to v{ target_branch_major_version } ' )
378- subprocess .check_output (['sed' , '-i' , f's/^## { source_branch_major_version } \./## { target_branch_major_version } ./g' , 'CHANGELOG.md' ])
379-
380- # process changelog for backport to target release branch
381- process_changelog_for_backports (target_branch_major_version )
380+ process_changelog_for_backports (source_branch_major_version , target_branch_major_version )
382381
383382 # Amend the commit generated by `npm version` to update the CHANGELOG
384383 run_git ('add' , 'CHANGELOG.md' )
0 commit comments