From: Dylan Baker Date: Thu, 5 Mar 2020 22:04:04 +0000 (-0800) Subject: bin/gen_release_notes.py: Fix version detection for .0 release X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0123b8f63415d3d320929e6112da2be2d837b262;p=mesa.git bin/gen_release_notes.py: Fix version detection for .0 release The previous version is being calculated incorrectly, resulting in 20.0.0 deciding it's version is 19.3.x+1. This fixes that. Fixes: 3226b12a09bbcbd25526fd6da6257057d26ddb31 ("release: Add an update_release_calendar.py script") Reviewed-by: Eric Engestrom Part-of: --- diff --git a/bin/gen_release_notes.py b/bin/gen_release_notes.py index f104e996049..48e216f80cf 100755 --- a/bin/gen_release_notes.py +++ b/bin/gen_release_notes.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright © 2019 Intel Corporation +# Copyright © 2019-2020 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bin/post_version.py b/bin/post_version.py index 5cf5f48615e..e05d177fe59 100755 --- a/bin/post_version.py +++ b/bin/post_version.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright © 2019 Intel Corporation +# Copyright © 2019-2020 Intel Corporation # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -33,32 +33,11 @@ from lxml import ( ) -def calculate_previous_version(version: str, is_point: bool) -> str: - """Calculate the previous version to compare to. - - In the case of -rc to final that verison is the previous .0 release, - (19.3.0 in the case of 20.0.0, for example). for point releases that is - the last point release. This value will be the same as the input value - for a poiont release, but different for a major release. - """ - if '-' in version: - version = version.split('-')[0] - if is_point: - return version - base = version.split('.') - if base[1] == '0': - base[0] = str(int(base[0]) - 1) - base[1] = '3' - else: - base[1] = str(int(base[1]) - 1) - return '.'.join(base) - - def is_point_release(version: str) -> bool: return not version.endswith('.0') -def update_index(is_point: bool, version: str, previous_version: str) -> None: +def update_index(is_point: bool, version: str) -> None: p = pathlib.Path(__file__).parent.parent / 'docs' / 'index.html' with p.open('rt') as f: tree = html.parse(f) @@ -72,13 +51,13 @@ def update_index(is_point: bool, version: str, previous_version: str) -> None: body = etree.Element('p') a = etree.SubElement( - body, 'a', attrib={'href': f'relnotes/{previous_version}.html'}) - a.text = f"Mesa {previous_version}" + body, 'a', attrib={'href': f'relnotes/{version}.html'}) + a.text = f"Mesa {version}" if is_point: a.tail = " is released. This is a bug fix release." else: a.tail = (" is released. This is a new development release. " - "See the release notes for mor information about this release.") + "See the release notes for more information about this release.") root = news.getparent() index = root.index(news) + 1 @@ -89,14 +68,14 @@ def update_index(is_point: bool, version: str, previous_version: str) -> None: subprocess.run(['git', 'add', p]) -def update_release_notes(previous_version: str) -> None: +def update_release_notes(version: str) -> None: p = pathlib.Path(__file__).parent.parent / 'docs' / 'relnotes.html' with p.open('rt') as f: tree = html.parse(f) li = etree.Element('li') - a = etree.SubElement(li, 'a', href=f'relnotes/{previous_version}.html') - a.text = f'{previous_version} release notes' + a = etree.SubElement(li, 'a', href=f'relnotes/{version}.html') + a.text = f'{version} release notes' ul = tree.xpath('.//ul')[0] ul.insert(0, li) @@ -105,12 +84,12 @@ def update_release_notes(previous_version: str) -> None: subprocess.run(['git', 'add', p]) -def update_calendar(previous_version: str) -> None: +def update_calendar(version: str) -> None: p = pathlib.Path(__file__).parent.parent / 'docs' / 'release-calendar.html' with p.open('rt') as f: tree = html.parse(f) - base_version = previous_version[:-2] + base_version = version[:-2] old = None new = None @@ -145,14 +124,13 @@ def main() -> None: args = parser.parse_args() is_point = is_point_release(args.version) - previous_version = calculate_previous_version(args.version, is_point) - update_index(is_point, args.version, previous_version) - update_release_notes(previous_version) - update_calendar(previous_version) + update_index(is_point, args.version) + update_release_notes(args.version) + update_calendar(args.version) subprocess.run(['git', 'commit', '-m', 'docs: update calendar, add news item, and link releases ' - f'notes for {previous_version}']) + f'notes for {args.version}']) if __name__ == "__main__":