How to use the dunamai.bump_version 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__bump_version():
    assert bump_version("1.2.3") == "1.2.4"

    assert bump_version("1.2.3", 0) == "2.0.0"
    assert bump_version("1.2.3", 1) == "1.3.0"
    assert bump_version("1.2.3", 2) == "1.2.4"

    assert bump_version("1.2.3", -1) == "1.2.4"
    assert bump_version("1.2.3", -2) == "1.3.0"
    assert bump_version("1.2.3", -3) == "2.0.0"

    with pytest.raises(IndexError):
        bump_version("1.2.3", 3)

    with pytest.raises(IndexError):
        bump_version("1.2.3", -4)

    with pytest.raises(ValueError):
        bump_version("foo", 0)
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
assert bump_version("1.2.3", 0) == "2.0.0"
    assert bump_version("1.2.3", 1) == "1.3.0"
    assert bump_version("1.2.3", 2) == "1.2.4"

    assert bump_version("1.2.3", -1) == "1.2.4"
    assert bump_version("1.2.3", -2) == "1.3.0"
    assert bump_version("1.2.3", -3) == "2.0.0"

    with pytest.raises(IndexError):
        bump_version("1.2.3", 3)

    with pytest.raises(IndexError):
        bump_version("1.2.3", -4)

    with pytest.raises(ValueError):
        bump_version("foo", 0)
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__bump_version():
    assert bump_version("1.2.3") == "1.2.4"

    assert bump_version("1.2.3", 0) == "2.0.0"
    assert bump_version("1.2.3", 1) == "1.3.0"
    assert bump_version("1.2.3", 2) == "1.2.4"

    assert bump_version("1.2.3", -1) == "1.2.4"
    assert bump_version("1.2.3", -2) == "1.3.0"
    assert bump_version("1.2.3", -3) == "2.0.0"

    with pytest.raises(IndexError):
        bump_version("1.2.3", 3)

    with pytest.raises(IndexError):
        bump_version("1.2.3", -4)

    with pytest.raises(ValueError):
        bump_version("foo", 0)
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__bump_version():
    assert bump_version("1.2.3") == "1.2.4"

    assert bump_version("1.2.3", 0) == "2.0.0"
    assert bump_version("1.2.3", 1) == "1.3.0"
    assert bump_version("1.2.3", 2) == "1.2.4"

    assert bump_version("1.2.3", -1) == "1.2.4"
    assert bump_version("1.2.3", -2) == "1.3.0"
    assert bump_version("1.2.3", -3) == "2.0.0"

    with pytest.raises(IndexError):
        bump_version("1.2.3", 3)

    with pytest.raises(IndexError):
        bump_version("1.2.3", -4)

    with pytest.raises(ValueError):
        bump_version("foo", 0)
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__bump_version():
    assert bump_version("1.2.3") == "1.2.4"

    assert bump_version("1.2.3", 0) == "2.0.0"
    assert bump_version("1.2.3", 1) == "1.3.0"
    assert bump_version("1.2.3", 2) == "1.2.4"

    assert bump_version("1.2.3", -1) == "1.2.4"
    assert bump_version("1.2.3", -2) == "1.3.0"
    assert bump_version("1.2.3", -3) == "2.0.0"

    with pytest.raises(IndexError):
        bump_version("1.2.3", 3)

    with pytest.raises(IndexError):
        bump_version("1.2.3", -4)

    with pytest.raises(ValueError):
        bump_version("foo", 0)
github mtkennerly / dunamai / tests / unit / test_dunamai.py View on Github external
def test__bump_version():
    assert bump_version("1.2.3") == "1.2.4"

    assert bump_version("1.2.3", 0) == "2.0.0"
    assert bump_version("1.2.3", 1) == "1.3.0"
    assert bump_version("1.2.3", 2) == "1.2.4"

    assert bump_version("1.2.3", -1) == "1.2.4"
    assert bump_version("1.2.3", -2) == "1.3.0"
    assert bump_version("1.2.3", -3) == "2.0.0"

    with pytest.raises(IndexError):
        bump_version("1.2.3", 3)

    with pytest.raises(IndexError):
        bump_version("1.2.3", -4)

    with pytest.raises(ValueError):
        bump_version("foo", 0)
github mtkennerly / poetry-dynamic-versioning / poetry_dynamic_versioning / __init__.py View on Github external
if style is not None:
        style = Style(style)

    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: