From abf9e7ac7bdb26ef203394ccdd5f0a43ceda1493 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 9 Oct 2019 10:31:16 -0700 Subject: [PATCH] bin/post_version.py: Pass version as an argument I made a bad assumption; I assumed this would be run in the release branch. But we don't do that, we run in the master branch. As a result we need to pass the version as an argument. Fixes: 3226b12a09bbcbd25526fd6da6257057d26ddb31 ("release: Add an update_release_calendar.py script") Reviewed-by: Eric Engestrom Reviewed-by: Juan A. Suarez --- bin/post_version.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/bin/post_version.py b/bin/post_version.py index 9afb37b18a3..2d195dce1b3 100755 --- a/bin/post_version.py +++ b/bin/post_version.py @@ -21,6 +21,7 @@ """Update the main page, release notes, and calendar.""" +import argparse import calendar import datetime import pathlib @@ -51,18 +52,8 @@ def calculate_previous_version(version: str, is_point: bool) -> str: return '.'.join(base) -def get_version() -> str: - v = pathlib.Path(__file__).parent.parent / 'VERSION' - with v.open('rt') as f: - raw_version = f.read().strip() - return raw_version.split('-')[0] - - -def is_point_release() -> bool: - v = pathlib.Path(__file__).parent.parent / 'VERSION' - with v.open('rt') as f: - raw_version = f.read().strip() - return '-rc' not in raw_version +def is_point_release(version: str) -> bool: + return not version.endswith('.0') def update_index(is_point: bool, version: str, previous_version: str) -> None: @@ -110,11 +101,14 @@ def update_release_notes(previous_version: str) -> None: def main() -> None: - is_point = is_point_release() - version = get_version() - previous_version = calculate_previous_version(version, is_point) + parser = argparse.ArgumentParser() + parser.add_argument('version', help="The released version.") + args = parser.parse_args() + + is_point = is_point_release(args.version) + previous_version = calculate_previous_version(args.version, is_point) - update_index(is_point, version, previous_version) + update_index(is_point, args.version, previous_version) update_release_notes(previous_version) -- 2.30.2