How to use the invocations.packaging.semantic_version_monkey.Version function in invocations

To help you get started, we’ve selected a few invocations 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 pyinvoke / invocations / tests / packaging / release.py View on Github external
def returns_lexica_for_reuse(self):
            actions = Lexicon(
                changelog=Changelog.NEEDS_RELEASE,
                version=VersionFile.NEEDS_BUMP,
                tag=Tag.NEEDS_CUTTING,
            )
            found_actions, found_state = _mock_status(self)
            assert found_actions == actions
            # Spot check state, don't need to check whole thing...
            assert found_state.branch == self._branch
            assert found_state.latest_version == Version("1.1.1")
            assert found_state.tags == [Version(x) for x in self._tags]
github pyinvoke / invocations / tests / packaging / release.py View on Github external
def next_patch_of_bugfix_release(self):
        versions = _latest_and_next_version(
            Lexicon(
                {
                    "release_type": Release.BUGFIX,
                    "latest_line_release": Version("1.2.2"),
                    "latest_overall_release": Version("1.4.1"),  # realism!
                }
            )
        )
        assert versions == (Version("1.2.2"), Version("1.2.3"))
github pyinvoke / invocations / tests / packaging / release.py View on Github external
def next_patch_of_bugfix_release(self):
        versions = _latest_and_next_version(
            Lexicon(
                {
                    "release_type": Release.BUGFIX,
                    "latest_line_release": Version("1.2.2"),
                    "latest_overall_release": Version("1.4.1"),  # realism!
                }
            )
        )
        assert versions == (Version("1.2.2"), Version("1.2.3"))
github pyinvoke / invocations / invocations / packaging / release.py View on Github external
def _get_tags(c):
    """
    Return sorted list of release-style tags as semver objects.
    """
    tags_ = []
    for tagstr in c.run("git tag", hide=True).stdout.strip().split("\n"):
        try:
            tags_.append(Version(tagstr))
        # Ignore anything non-semver; most of the time they'll be non-release
        # tags, and even if they are, we can't reason about anything
        # non-semver anyways.
        # TODO: perhaps log these to DEBUG
        except ValueError:
            pass
    # Version objects sort semantically
    return sorted(tags_)
github pyinvoke / invocations / invocations / packaging / release.py View on Github external
def _versions_from_changelog(changelog):
    """
    Return all released versions from given ``changelog``, sorted.

    :param dict changelog:
        A changelog dict as returned by ``releases.util.parse_changelog``.

    :returns: A sorted list of `semantic_version.Version` objects.
    """
    versions = [Version(x) for x in changelog if BUGFIX_RELEASE_RE.match(x)]
    return sorted(versions)
github pyinvoke / invocations / invocations / packaging / release.py View on Github external
# current line
    line_release, issues = _release_and_issues(changelog, branch, release_type)
    # Also get latest overall release, sometimes that matters (usually only
    # when latest *appropriate* release doesn't exist yet)
    overall_release = _versions_from_changelog(changelog)[-1]
    # Obtain the project's main package & its version data
    current_version = load_version(c)
    # Grab all git tags
    tags = _get_tags(c)

    state = Lexicon(
        {
            "branch": branch,
            "release_type": release_type,
            "changelog": changelog,
            "latest_line_release": Version(line_release)
            if line_release
            else None,
            "latest_overall_release": overall_release,  # already a Version
            "unreleased_issues": issues,
            "current_version": Version(current_version),
            "tags": tags,
        }
    )
    # Version number determinations:
    # - latest actually-released version
    # - the next version after that for current branch
    # - which of the two is the actual version we're looking to converge on,
    # depends on current changelog state.
    latest_version, next_version = _latest_and_next_version(state)
    state.latest_version = latest_version
    state.next_version = next_version