@@ -175,7 +175,7 @@ def get_today_string():
175
175
today = datetime .datetime .today ()
176
176
return '{:%d %b %Y}' .format (today )
177
177
178
- def process_changelog_for_backports (target_version ):
178
+ def process_changelog_for_backports (source_branch_major_version , target_branch_major_version ):
179
179
180
180
# changelog entries use a speficic format to indicate
181
181
# that they only apply to newer versions
@@ -191,6 +191,7 @@ def process_changelog_for_backports(target_version):
191
191
192
192
output += line + '\n '
193
193
if line .startswith ('## ' ):
194
+ line = line .replace (f'## { source_branch_major_version } ' , f'## { target_branch_major_version } ' )
194
195
# we have found the first section, so now handle things differently
195
196
break
196
197
@@ -206,10 +207,11 @@ def process_changelog_for_backports(target_version):
206
207
# filter out changenote entries that apply only to newer versions
207
208
match = regex .search (line )
208
209
if match :
209
- if int (target_version ) < int (match .group (1 )):
210
+ if int (target_branch_major_version ) < int (match .group (1 )):
210
211
continue
211
212
212
213
if line .startswith ('## ' ):
214
+ line = line .replace (f'## { source_branch_major_version } ' , f'## { target_branch_major_version } ' )
213
215
if found_content == False :
214
216
# we have found two headings in a row, so we need to add the placeholder message.
215
217
output += 'No user facing changes.\n '
@@ -375,10 +377,7 @@ def main():
375
377
376
378
# Migrate the changelog notes from vLatest version numbers to vOlder version numbers
377
379
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 )
382
381
383
382
# Amend the commit generated by `npm version` to update the CHANGELOG
384
383
run_git ('add' , 'CHANGELOG.md' )
0 commit comments