From e6ab6fbc681bbea1fb49d7829425957c8281723d Mon Sep 17 00:00:00 2001 From: Michael Boniface <m.j.boniface@soton.ac.uk> Date: Thu, 27 Feb 2025 08:35:33 +0000 Subject: [PATCH] fix: added version message to publish --- acmc/main.py | 5 ++++- acmc/phen.py | 6 ++++-- docs/usage.md | 3 ++- tests/test_acmc.py | 14 ++++++++++++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/acmc/main.py b/acmc/main.py index cf7ffbb..ec29b5d 100644 --- a/acmc/main.py +++ b/acmc/main.py @@ -53,7 +53,7 @@ def phen_export(args): def phen_publish(args): """Handle the `phen publish` command.""" - phen.publish(args.phen_dir, args.remote_url) + phen.publish(args.phen_dir, args.msg, args.remote_url) def phen_copy(args): @@ -203,6 +203,9 @@ def main(): default=str(phen.DEFAULT_PHEN_PATH.resolve()), help="Phenotype workspace directory", ) + phen_publish_parser.add_argument( + "-m", "--msg", help="Message to include with the published version" + ) phen_publish_parser.add_argument( "-r", "--remote_url", help="URL to remote git repository" ) diff --git a/acmc/phen.py b/acmc/phen.py index 23c8ac7..d35d3bf 100644 --- a/acmc/phen.py +++ b/acmc/phen.py @@ -766,7 +766,7 @@ def map_target_code_type(phen_path, phenotype, target_code_type): logger.info(f"Phenotype processed target code type {target_code_type}") -def publish(phen_dir, remote_url): +def publish(phen_dir, msg, remote_url): """Publishes updates to the phenotype by commiting all changes to the repo directory""" # Validate config @@ -821,7 +821,9 @@ def publish(phen_dir, remote_url): # Create and push the tag if version in repo.tags: raise Exception(f"Tag {version} already exists in repo {phen_path}") - repo.create_tag(version, message=f"Release {version}") + if msg is None: + msg = f"Release {version}" + repo.create_tag(version, message=msg) logger.info(f"New version: {version}") # push to origin if a remote repo diff --git a/docs/usage.md b/docs/usage.md index 29c1ba7..b364849 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -108,7 +108,8 @@ The `phen` command is used phenotype-related operations. ``` - `-d`, `--phen-dir`: (Optional) Directory of phenotype configuration (the default is ./build/phen). - - `-r`, `--remote_url`: (Optional) URL to a remote git repository, only supports an empty repo without existing commits + - `-m`, `--msg`: (Optional) Message to include with the published version- + - `-r`, `--remote_url`: (Optional) URL to a remote git repository, only supports an empty repo without existing commits. - **Copy Phenotype Configuration** diff --git a/tests/test_acmc.py b/tests/test_acmc.py index c4cb94e..4b7e82d 100644 --- a/tests/test_acmc.py +++ b/tests/test_acmc.py @@ -109,10 +109,20 @@ def test_phen_workflow(tmp_dir, monkeypatch, caplog, config_file): main.main() assert "Phenotype processed successfully" in caplog.text - # publish phenotype + # publish phenotype with version message with caplog.at_level(logging.DEBUG): monkeypatch.setattr( - sys, "argv", ["main.py", "phen", "publish", "-d", str(phen_path.resolve())] + sys, + "argv", + [ + "main.py", + "phen", + "publish", + "-d", + str(phen_path.resolve()), + "-m", + "version message", + ], ) main.main() assert "Phenotype published successfully" in caplog.text -- GitLab