Skip to content

Commit

Permalink
Factor out constructing path to version.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Dec 11, 2024
1 parent 8a5c173 commit 5f03294
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions galaxy_release_util/point_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Expand All @@ -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

Expand Down Expand Up @@ -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,
)
Expand Down
11 changes: 7 additions & 4 deletions galaxy_release_util/util.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5f03294

Please sign in to comment.