How to use the dunamai.Vcs.Any 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__version__from_any_vcs(tmp_path) -> None:
    with chdir(tmp_path):
        with pytest.raises(RuntimeError):
            Version.from_any_vcs()
        with pytest.raises(RuntimeError):
            Version.from_vcs(Vcs.Any)
github mtkennerly / dunamai / tests / integration / test_dunamai.py View on Github external
assert from_vcs() == Version("0.1.0", commit="abc", dirty=False)
        assert from_vcs(latest_tag=True) == Version("0.1.0", commit="abc", dirty=False)
        assert run("dunamai from git") == "0.1.0"
        assert run("dunamai from any") == "0.1.0"

        # Additional one-off checks not in other VCS integration tests:
        assert run(r'dunamai from any --pattern "(?P\d\.\d\.\d)"') == "0.1.0"
        run(r'dunamai from any --pattern "(\d\.\d\.\d)"', 1)
        assert run('dunamai from any --format "v{base}"') == "v0.1.0"
        assert run('dunamai from any --style "semver"') == "0.1.0"
        assert (
            run('dunamai from any --format "v{base}" --style "semver"', 1)
            == "Version 'v0.1.0' does not conform to the Semantic Versioning style"
        )
        assert run("dunamai from any --latest-tag") == "0.1.0"
        assert from_explicit_vcs(Vcs.Any) == Version("0.1.0", commit="abc", dirty=False)
        assert from_explicit_vcs(Vcs.Git) == Version("0.1.0", commit="abc", dirty=False)

        (vcs / "foo.txt").write_text("bye")
        assert from_vcs() == Version("0.1.0", commit="abc", dirty=True)

        run("git add .")
        run('git commit -m "Second"')
        assert from_vcs() == Version("0.1.0", distance=1, commit="abc", dirty=False)
        assert from_any_vcs() == Version("0.1.0", distance=1, commit="abc", dirty=False)

        run("git tag unmatched")
        assert from_vcs() == Version("0.1.0", distance=1, commit="abc", dirty=False)
        with pytest.raises(ValueError):
            from_vcs(latest_tag=True)

        run("git tag v0.2.0 -m 'Annotated'")
github mtkennerly / dunamai / dunamai / __main__.py View on Github external
"triggers": ["--debug"],
        "action": "store_true",
        "dest": "debug",
        "default": False,
        "help": "Display additional information on stderr for troubleshooting",
    },
]
cli_spec = {
    "description": "Generate dynamic versions",
    "sub_dest": "command",
    "sub": {
        "from": {
            "description": "Generate version from a particular VCS",
            "sub_dest": "vcs",
            "sub": {
                Vcs.Any.value: {
                    "description": "Generate version from any detected VCS",
                    "args": [
                        *common_sub_args,
                        {
                            "triggers": ["--tag-dir"],
                            "default": "tags",
                            "help": "Location of tags relative to the root (Subversion)",
                        },
                    ],
                },
                Vcs.Git.value: {
                    "description": "Generate version from Git",
                    "args": common_sub_args,
                },
                Vcs.Mercurial.value: {
                    "description": "Generate version from Mercurial",