`incremental update --rc` treats rc0 as not being a release candidate

未关闭 适合新手
#214 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
cli

调研方向

从 src/incremental/update.py 开始:if existing.release_candidate: 检查在 L105(--rc bump)、L156(完整发布路径)和 L180(重写现有 rc 引用)附近,对 rc0 而言全为 false。把它们改为 is not None 测试,并顺便检查 Version.__init__ 对 prerelease 的处理,在 src/incremental/_version.py 中。先运行 issue 中的复现以确认 30.6.0rc1,然后在 src/incremental/tests/test_update.py 中现有测试旁边添加一个回归测试;完成意味着 rc0 情况得到 24.1.0rc1 且测试套件通过。

由索引模型根据 Issue 内容生成。

描述

When the current version is a release candidate with number 0 (e.g. 24.1.0rc0), incremental update <pkg> --rc starts a new calendar version instead of bumping to rc1. With rc1 the bump works as documented.

Environment: incremental 24.11.0, Python 3.12

Reproduction (calls the function behind the CLI so the date is fixed; equivalent to incremental update Shrubbery --rc)

import datetime, json, pathlib, tempfile
from incremental.update import _run

result = []
for rc in [0, 1]:
    with tempfile.TemporaryDirectory() as t:
        p = pathlib.Path(t)
        f = p / '_version.py'
        f.write_text(
            'from incremental import Version\n'
            f'__version__ = Version("Shrubbery", 24, 1, 0, release_candidate={rc})\n'
        )
        _run('Shrubbery', str(p), None, False, True, False, False, False,
             _date=datetime.date(2030, 6, 1), _print=lambda x: None)
        ns = {}
        exec(f.read_text(), ns)
        result.append(ns['__version__'].public())
print(json.dumps(result))

Actual

["30.6.0rc1", "24.1.0rc2"]

Expected

["24.1.0rc1", "24.1.0rc2"]

The README says release_candidate can be "set to 0 or higher to mark this Version being of a release candidate", and that --rc will "bump the release candidate number by 1 if it is" one. An rc0 version can come from --newversion 24.1.0rc0 (or 24.1.0rc, which PEP 440 normalizes to rc0).

Likely cause: if existing.release_candidate: is false for 0. From reading the code, the same check is used for the no-argument "make a full release" path (L156) and when rewriting existing rc references (L180), so those probably mis-handle rc0 as well (I have not run them); is not None would fix all three. Version(..., prerelease=0) has a similar truthiness check in __init__, though that argument is deprecated.

Found while testing the library with an automated exploration tool; the reproduction above was re-run on 24.11.0 before filing.

主要语言
Python
星标
145
派生
22
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

twisted/incremental 的其他 Issue

查看 twisted/incremental 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。