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

オープン 初心者向け
#214 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

twisted/incremental のほかの issue

twisted/incremental の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。