Skip to content
Snippets Groups Projects
Commit e6ab6fbc authored by mjbonifa's avatar mjbonifa
Browse files

fix: added version message to publish

parent 196f1306
No related branches found
No related tags found
No related merge requests found
......@@ -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"
)
......
......@@ -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
......
......@@ -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**
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment