Python bump2version在删除发布后段的同时增加发布前版本
我将如何使用(关于其调用和/或配置)来增加:Python bump2version在删除发布后段的同时增加发布前版本,python,python-3.x,bump2version,Python,Python 3.x,Bump2version,我将如何使用(关于其调用和/或配置)来增加: 1.0.0.a2.post0 # post-release of a pre-release a2 到 可复制示例: $python3-mpip安装'bump2version==1.0.*' \uuuu init\uuuuu.py: \uuuu version=“1.0.0.a2.post0” setup.cfg: [bumpversion] current_version = 1.0.0.a2.post0 parse = ^ (?P&
1.0.0.a2.post0 # post-release of a pre-release a2
到
可复制示例:
$python3-mpip安装'bump2version==1.0.*'
\uuuu init\uuuuu.py
:
\uuuu version=“1.0.0.a2.post0”
setup.cfg
:
[bumpversion]
current_version = 1.0.0.a2.post0
parse = ^
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) # minimum major.minor.patch, 1.2.3
(?:
\.
(?P<prerel>a|alpha|b|beta|d|dev|rc) # pre-release segment
(?P<prerelversion>\d+) # pre-release version num
)?
(?:\.post(?P<post>\d+))? # post-release
serialize =
{major}.{minor}.{patch}.{prerel}{prerelversion}.post{post}
{major}.{minor}.{patch}.{prerel}{prerelversion}
{major}.{minor}.{patch}.post{post}
{major}.{minor}.{patch}
[bumpversion:file:__init__.py]
[bumpversion:part:prerel]
optional_value = dev
values =
dev
d
alpha
a
beta
b
rc
例如,我尝试过使用bump2version--verbose prerelversion
或者显式地使用--new version=1.0.0.a3
。这两次尝试都保留了.post0
,而不是丢弃它
注:几周前,我在bump2version回购协议中提出了这一问题,但运气不佳。我们必须解决这一问题(过去,我们使用的是原始的
bump2version
,而不是更好的bump2version
)
通过下面的配置,您可以使用bumpversion pre
从1.0.0.a2.post0
转到1.0.0.a3
说明:
由于pre
和post
都有一个字符串前缀和一个数字,因此我认为有必要对它们进行相应的拆分。例如,pre
部分可以分为prekind
(字符串)和pre
(数字)。然后,很好的一点是,您可以独立于发行编号(通常是一个序列)增加prekind
('dev'
到'alpha'
到'beta'
等)
下面,我列出了一个完整的配置和一个示例,其中包含了一系列顺序调用,以显示可能发生的各种变化。我相信下面的设置可以进一步定制,但希望它能让你和其他人在正确的轨道上登陆
cat>.bumpversion.cfg我只看到了一个问题,那就是bumpingprekind
不太正确,因为它将a
/alpha
和b
/beta
视为同义词,而将它们视为顺序。例如,bump2version-prekind
将bumpbeta0
->b0
。不确定是否有方法使value
识别“同等级别”版本段的元组。查看代码(并在调试器中运行测试),尤其是函数。在主机上的ValuesFunction
(在您自己提交时:2346ff6
),它看起来不像提供了任何同义词机制。我想这并不难实现,而且非常有用。首先定义:可能允许部件可以采用的值列表中的数组,而不是简单的字符串(例如:values:[dev[a,alpha],[b,beta],…])
。顺便说一句,对你的问题最相关的测试之一是tests.test\u cli.test\u python\u pre\u release\u release\u post\u release
。是的,我刚刚发现test funct也可以。谢谢考虑提交一份PR,以允许该类型的值
schemathx在那里领导费用,@bradsomon;FWIW,我们在所有软件包中广泛使用bump2version
,我相信世界各地的许多团队也这样做。我个人非常感激。
[bumpversion]
current_version = 1.0.0.a2.post0
parse = ^
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) # minimum major.minor.patch, 1.2.3
(?:
\.
(?P<prerel>a|alpha|b|beta|d|dev|rc) # pre-release segment
(?P<prerelversion>\d+) # pre-release version num
)?
(?:\.post(?P<post>\d+))? # post-release
serialize =
{major}.{minor}.{patch}.{prerel}{prerelversion}.post{post}
{major}.{minor}.{patch}.{prerel}{prerelversion}
{major}.{minor}.{patch}.post{post}
{major}.{minor}.{patch}
[bumpversion:file:__init__.py]
[bumpversion:part:prerel]
optional_value = dev
values =
dev
d
alpha
a
beta
b
rc
1.2.3 # (1) final
1.2.3.dev0 # (2) prerelease
1.2.3.a0
1.2.3.alpha0
1.2.3.b0
1.2.3.beta0
1.2.3.rc0
1.2.3.rc3.post0 # (3) postrelease (of a pre-release version)
1.2.3.post0 # (4) postrelease (of a final version)
starting from: 1.0.0.a2.post0
post --> 1.0.0.a2.post1 # no issue incrementing post
post --> 1.0.0.a2.post2
pre --> 1.0.0.a3 # can move to the next 'pre'release
pre --> 1.0.0.a4
prekind --> 1.0.0.beta0 # can upgrade the kind of prerelease
prekind --> 1.0.0.b0
pre --> 1.0.0.b1 # and keep incrementing
postkind --> 1.0.0.b1.post0 # bring a post component again
post --> 1.0.0.b1.post1 # and incrementing
prekind --> 1.0.0.rc0 # upgrade pre kind directly
minor --> 1.1.0 # patch/minor/major cut the optional parts
postkind --> 1.1.0.post0 # but we can bring a post component (without pre)
post --> 1.1.0.post1
pre --> 1.1.0 # BAD & silent: cannot increment a missing part
postkind --> 1.1.0.post0
prekind --> 1.1.0.dev0 # default: pre part starts at 'dev'
postkind --> 1.1.0.dev0.post0 # can add post part to a pre part
post --> 1.1.0.dev0.post1 # etc...
major --> 2.0.0
prekind --> 2.0.0.dev0
postkind --> 2.0.0.dev0.post0
post --> 2.0.0.dev0.post1