diff --git a/acmc/main.py b/acmc/main.py index cf7ffbbfe88a9afb6fbeb7cd4405b59dc8034e25..e2765e8abeab17375e75ebd2ae3ca5dfc0a939d7 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): @@ -66,6 +66,7 @@ def phen_diff(args): phen.diff(args.phen_dir, args.phen_dir_old) + def main(): parser = argparse.ArgumentParser(description="ACMC command-line tool") parser.add_argument("--debug", action="store_true", help="Enable debug mode") @@ -203,6 +204,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 23c8ac728cb5445c23f6da56e9b91befcb5f6ab4..d35d3bf56fc81b7a97cda794b0840058bc6d0d62 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 29c1ba7410afb354285e395debc9cc41c8169cc2..b36484928dcca7219429f45c3c0566af941f5553 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 c4cb94efcc2630ff0285489525049d0fa41ab047..4b7e82df34b2c213fcc5606afaadf14593f7e56f 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