From af6f872c573ac5287a2fc0fa145481414fb76b6a Mon Sep 17 00:00:00 2001 From: Suvayu Ali Date: Fri, 4 Oct 2024 03:05:06 +0200 Subject: [PATCH] publish.py: push tags only for packages included in pkgtags --- orchestra/publish.py | 2 ++ tests/test_publish.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/orchestra/publish.py b/orchestra/publish.py index 870922a..48c4903 100644 --- a/orchestra/publish.py +++ b/orchestra/publish.py @@ -107,6 +107,8 @@ def publish_tags_whls(CONF: dict, pkgtags: Path): """ tags = json.loads(pkgtags.read_text()) for pkg, repo_path in CONF["repos"].items(): + if pkg not in tags: + continue repo = Repo(repo_path) push_tags(CONF, pkg, repo, tags[remote_name(repo)]) dispatch_workflow(CONF, pkgtags) diff --git a/tests/test_publish.py b/tests/test_publish.py index 04aa687..505410b 100644 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -1,4 +1,5 @@ from io import StringIO +import json from pathlib import Path import sys @@ -6,7 +7,7 @@ import pytest from orchestra import ErrorCodes -from orchestra.publish import dispatch_workflow, push_tags +from orchestra.publish import dispatch_workflow, publish_tags_whls, push_tags from .conftest import commit, edit, example_pkgs @@ -106,3 +107,16 @@ def test_dispatch_workflow(CONF, cmd, monkeypatch): *_, token = cmd.split() # the .strip is required on windows as we call powershell explicitly assert token.strip("'\"") in out + + +@pytest.mark.parametrize("dup_repos", ["scm"], indirect=True) +@pytest.mark.parametrize("cmd", ["echo {repo} {workflow}"]) +def test_publish_tags_whls(CONF, dup_repos, cmd, monkeypatch): + name, _, src, dst = dup_repos + monkeypatch.setattr("sys.stdin", StringIO("0")) + dst.create_tag("test_tag") + pkgtags = Path(f"{dst.working_dir}/pkgtags.json") + pkgtags.write_text(json.dumps({"scm": "test_tag"})) + + # FIXME: is this sufficient? + publish_tags_whls(CONF, pkgtags)