1

我正在使用bump2version语义版本控制。如果主要版本为 0(即快速开发?),有没有办法防止标签的预发布组件出现。就目前而言,我.bumpversion.cfg的是

[bumpversion]
current_version = 0.0.0
tag = False
tag_name = {new_version}
commit = True
parse =
    (?P<major>\d+)
    \.
    (?P<minor>\d+)
    \.
    (?P<patch>\d+)
    (\-(?P<pre>[a-z]+)\.(?P<prenum>\d+))?
serialize =
    {major}.{minor}.{patch}-{pre}.{prenum}
    {major}.{minor}.{patch}

[bumpversion:part:pre]
optional_value = placeholder
first_value = alpha
values =
    alpha
    beta
    rc
    placeholder

[bumpversion:part:prenum]
first_value = 1

[bumpversion:file:pyproject.toml]

当我碰撞部分时添加预发布值minor

>>> bumpversion minor
Bumpversion: 0.0.0 -> 0.1.0-alpha.1

当我处于主要版本时,我不希望标签的-alpha.N,等部分出现(即快速开发;在主要版本和更高版本之前不会对我进行预发布测试)。-beta.N01

0从主要版本到1全部版本时N,我确实想要预发布部分(因为预发布测试将在这些阶段进行),而不是为了快速开发。在快速开发过程中,我不希望每次颠簸都必须手动输入(尤其是因为在 1.0.0 之前我会有很多版本)。N+1N > 0--new-version

有没有人有办法解决吗?

4

1 回答 1

1

作为“猴子补丁”/解决方法,在 中bumpversion.version_part,我_choose_serialize_format()

def _choose_serialize_format(self, version, context):

        chosen = None

        logger.debug(
            "Available serialization formats: '%s'", "', '".join(self.serialize_formats)
        )

        for serialize_format in self.serialize_formats:
            try:
                self._serialize(
                    version, serialize_format, context, raise_if_incomplete=True
                )
                chosen = serialize_format
                logger.debug("Found '%s' to be a usable serialization format", chosen)
            except IncompleteVersionRepresentationException as e:
                if not chosen:
                    chosen = serialize_format
            except MissingValueForSerializationException as e:
                logger.info(e.message)
                raise e

        if not chosen:
            raise KeyError("Did not find suitable serialization format")

        logger.debug("Selected serialization format '%s'", chosen)

        return chosen

def _choose_serialize_format(self, version, context):

        chosen = None

        logger.debug(
            "Available serialization formats: '%s'", "', '".join(self.serialize_formats)
        )

        if version._values["major"].value == "0":
            _serialize_formats = [
                self.serialize_formats[-1],
            ]
        else:
            _serialize_formats = self.serialize_formats

        for serialize_format in _serialize_formats:
            try:
                self._serialize(
                    version, serialize_format, context, raise_if_incomplete=True
                )
                chosen = serialize_format
                logger.debug("Found '%s' to be a usable serialization format", chosen)
            except IncompleteVersionRepresentationException as e:
                if not chosen:
                    chosen = serialize_format
            except MissingValueForSerializationException as e:
                logger.info(e.message)
                raise e

        if not chosen:
            raise KeyError("Did not find suitable serialization format")

        logger.debug("Selected serialization format '%s'", chosen)

        return chosen

添加的行是

if version._values["major"].value == "0":
    _serialize_formats = [
        self.serialize_formats[-1],
    ]
else:
    _serialize_formats = self.serialize_formats

并且更改的行是

for serialize_format in self.serialize_formats:

for serialize_format in _serialize_formats:
于 2021-04-29T22:19:51.947 回答