diff --git a/galaxy_release_util/point_release.py b/galaxy_release_util/point_release.py index d040d17..121d193 100644 --- a/galaxy_release_util/point_release.py +++ b/galaxy_release_util/point_release.py @@ -33,7 +33,10 @@ _text_target, strip_release, ) -from .util import verify_galaxy_root +from .util import ( + verify_galaxy_root, + version_filepath, +) g = github_client() PROJECT_OWNER = "galaxyproject" @@ -354,7 +357,7 @@ def upload_package(package: Package): def get_root_version(galaxy_root: pathlib.Path) -> Version: - version_py = galaxy_root / "lib" / "galaxy" / "version.py" + version_py = version_filepath(galaxy_root) version_py_contents = version_py.read_text().splitlines() assert len(version_py_contents) == 3 major_version = version_py_contents[0].split('"')[1] @@ -369,7 +372,7 @@ def set_root_version(galaxy_root: pathlib.Path, new_version: Version) -> pathlib VERSION_MINOR = "{minor_galaxy_release_string}" VERSION = VERSION_MAJOR + (f".{{VERSION_MINOR}}" if VERSION_MINOR else "") """ - version_py = galaxy_root / "lib" / "galaxy" / "version.py" + version_py = version_filepath(galaxy_root) version_py.write_text(VERSION_PY_TEMPLATE) return version_py @@ -443,7 +446,7 @@ def merge_and_resolve_branches( "git", "checkout", new_branch, - str(galaxy_root / "lib" / "galaxy" / "version.py"), + str(version_filepath(galaxy_root)), ], cwd=galaxy_root, ) diff --git a/galaxy_release_util/util.py b/galaxy_release_util/util.py index 6746c7c..bdd9a1e 100644 --- a/galaxy_release_util/util.py +++ b/galaxy_release_util/util.py @@ -1,9 +1,12 @@ import os -import pathlib +from pathlib import Path -def verify_galaxy_root(galaxy_root: pathlib.Path): - version_file = pathlib.Path(galaxy_root / "lib" / "galaxy" / "version.py") - if not os.path.exists(version_file): +def version_filepath(galaxy_root: Path) -> Path: + return Path(galaxy_root / "lib" / "galaxy" / "version.py") + + +def verify_galaxy_root(galaxy_root: Path): + if not os.path.exists(version_filepath(galaxy_root)): msg = f"Galaxy files not found at `{galaxy_root}`. If you are running this script outside of galaxy root directory, you should specify the '--galaxy-root' argument" raise Exception(msg)