How to use the dunamai.serialize_semver function in dunamai

To help you get started, we’ve selected a few dunamai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_semver():
    assert serialize_semver("1.2.3") == "1.2.3"
    assert serialize_semver("1.2.3", pre=["alpha"]) == "1.2.3-alpha"
    assert serialize_semver("1.2.3", pre=["alpha", 4]) == "1.2.3-alpha.4"
    assert serialize_semver("1.2.3", metadata=["foo"]) == "1.2.3+foo"
    assert serialize_semver("1.2.3", metadata=["foo", "bar"]) == "1.2.3+foo.bar"
    assert serialize_semver("1.2.3", metadata=[4]) == "1.2.3+4"

    assert (
        serialize_semver("1.2.3", pre=["alpha", 4], metadata=["foo", "bar"])
        == "1.2.3-alpha.4+foo.bar"
    )

    with pytest.raises(ValueError):
        serialize_semver("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_semver():
    assert serialize_semver("1.2.3") == "1.2.3"
    assert serialize_semver("1.2.3", pre=["alpha"]) == "1.2.3-alpha"
    assert serialize_semver("1.2.3", pre=["alpha", 4]) == "1.2.3-alpha.4"
    assert serialize_semver("1.2.3", metadata=["foo"]) == "1.2.3+foo"
    assert serialize_semver("1.2.3", metadata=["foo", "bar"]) == "1.2.3+foo.bar"
    assert serialize_semver("1.2.3", metadata=[4]) == "1.2.3+4"

    assert (
        serialize_semver("1.2.3", pre=["alpha", 4], metadata=["foo", "bar"])
        == "1.2.3-alpha.4+foo.bar"
    )

    with pytest.raises(ValueError):
        serialize_semver("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_semver():
    assert serialize_semver("1.2.3") == "1.2.3"
    assert serialize_semver("1.2.3", pre=["alpha"]) == "1.2.3-alpha"
    assert serialize_semver("1.2.3", pre=["alpha", 4]) == "1.2.3-alpha.4"
    assert serialize_semver("1.2.3", metadata=["foo"]) == "1.2.3+foo"
    assert serialize_semver("1.2.3", metadata=["foo", "bar"]) == "1.2.3+foo.bar"
    assert serialize_semver("1.2.3", metadata=[4]) == "1.2.3+4"

    assert (
        serialize_semver("1.2.3", pre=["alpha", 4], metadata=["foo", "bar"])
        == "1.2.3-alpha.4+foo.bar"
    )

    with pytest.raises(ValueError):
        serialize_semver("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_semver():
    assert serialize_semver("1.2.3") == "1.2.3"
    assert serialize_semver("1.2.3", pre=["alpha"]) == "1.2.3-alpha"
    assert serialize_semver("1.2.3", pre=["alpha", 4]) == "1.2.3-alpha.4"
    assert serialize_semver("1.2.3", metadata=["foo"]) == "1.2.3+foo"
    assert serialize_semver("1.2.3", metadata=["foo", "bar"]) == "1.2.3+foo.bar"
    assert serialize_semver("1.2.3", metadata=[4]) == "1.2.3+4"

    assert (
        serialize_semver("1.2.3", pre=["alpha", 4], metadata=["foo", "bar"])
        == "1.2.3-alpha.4+foo.bar"
    )

    with pytest.raises(ValueError):
        serialize_semver("foo")
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__serialize_semver():
    assert serialize_semver("1.2.3") == "1.2.3"
    assert serialize_semver("1.2.3", pre=["alpha"]) == "1.2.3-alpha"
    assert serialize_semver("1.2.3", pre=["alpha", 4]) == "1.2.3-alpha.4"
    assert serialize_semver("1.2.3", metadata=["foo"]) == "1.2.3+foo"
    assert serialize_semver("1.2.3", metadata=["foo", "bar"]) == "1.2.3+foo.bar"
    assert serialize_semver("1.2.3", metadata=[4]) == "1.2.3+4"

    assert (
        serialize_semver("1.2.3", pre=["alpha", 4], metadata=["foo", "bar"])
        == "1.2.3-alpha.4+foo.bar"
    )

    with pytest.raises(ValueError):
        serialize_semver("foo")
github mtkennerly / poetry-dynamic-versioning / poetry_dynamic_versioning / __init__.py View on Github external
version = Version.from_vcs(
        vcs, config["pattern"], config["latest-tag"], config["subversion"]["tag-dir"]
    )
    if config["format-jinja"]:
        default_context = {
            "base": version.base,
            "stage": version.stage,
            "revision": version.revision,
            "distance": version.distance,
            "commit": version.commit,
            "dirty": version.dirty,
            "env": os.environ,
            "bump_version": bump_version,
            "serialize_pep440": serialize_pep440,
            "serialize_pvp": serialize_pvp,
            "serialize_semver": serialize_semver,
        }
        custom_context = {}  # type: dict
        for entry in config["format-jinja-imports"]:
            if "module" in entry:
                module = import_module(entry["module"])
                if "item" in entry:
                    custom_context[entry["item"]] = getattr(module, entry["item"])
                else:
                    custom_context[entry["module"]] = module
        serialized = jinja2.Template(config["format-jinja"]).render(
            **default_context, **custom_context
        )
        if style is not None:
            check_version(serialized, style)
    else:
        serialized = version.serialize(config["metadata"], config["dirty"], config["format"], style)