Skip to content

Commit dd88c25

Browse files
Dariquestmaxmoehl
authored andcommitted
Fix for major and minor version jumps
1 parent a6cd877 commit dd88c25

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

ci/scripts/autobump-dependencies.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,26 @@ def fetch_latest_release(self) -> Release:
356356
version.parse(latest_version),
357357
)
358358

359-
def get_release_notes(self) -> str:
359+
def _get_comparison_versions(self):
360+
""" HAProxy tracks each minor version in a dedicated repository and the changelog in each repository only ever
361+
observes the .0 of previous minor versions as they are split off into a dedicated repository at that point.
362+
To make a comparison across major and minor versions we need to compare against the .0 of the previous minor
363+
version, this helper converts the comparison base accordingly.
364+
"""
360365
current_version = self.current_version
361366
latest_version = self.latest_release.version
367+
if latest_version.major > current_version.major or latest_version.minor > current_version.minor:
368+
current_version = version.Version(f"{current_version.major}.{current_version.minor}.0")
369+
370+
return str(current_version), str(latest_version)
371+
372+
def get_release_notes(self) -> str:
373+
374+
if self.current_version == self.latest_release.version:
375+
raise Exception(f"""Changelog requested for identical current and latest versions: {self.current_version}""")
362376

363-
if (current_version == latest_version):
364-
raise Exception(f"""Changelog requested but current and latest versions are the same: {current_version}""")
377+
# Set patch part of the current version to 0 for minor and major version bumps
378+
current_version, latest_version = self._get_comparison_versions()
365379

366380
releaseNote = textwrap.dedent(f"""
367381
[Changelog for HAProxy {latest_version}](https://www.haproxy.org/download/{HAPROXY_VERSION}/src/CHANGELOG).
@@ -383,13 +397,20 @@ def get_release_notes(self) -> str:
383397

384398
startCopy = False
385399
for line in file:
386-
if (line.endswith(str(latest_version)+"\n")): # Start copying from latest version head
400+
if (line.endswith(latest_version+"\n")): # Start copying from latest version head
387401
startCopy = True
388-
if (line.endswith(str(current_version)+"\n")): # Stop when reaching current version
402+
if (line.endswith(current_version+"\n")): # Stop when reaching current version
389403
break
390404
if not startCopy:
391405
continue
392406
releaseNote += line
407+
# PR body length is limited by 65536 characters, truncating the change log to 60000 to avoid a validation error
408+
releaseNoteLimit = 60000
409+
if len(releaseNote) > releaseNoteLimit:
410+
releaseNote = releaseNote[:releaseNoteLimit] + textwrap.dedent(f"""
411+
412+
Change log was trimmed to {releaseNoteLimit} characters. Please see the changelog file for the full change log.
413+
""")
393414

394415
releaseNote += textwrap.dedent(f"""
395416
```

0 commit comments

Comments
 (0)