简体   繁体   English

语义版本控制:我可以将 git 标签移动到不同的提交吗?

[英]Semantic versioning: Am I allowed to move git tags to a different commit?

Let's say I tagged commit A of my library with tag v1.0.0.假设我用标签 v1.0.0 标记了我的库的提交A

Now, I make a minor fix in the API documentation, let's say, fixing a typo.现在,我在 API 文档中做了一个小修复,比如说,修复一个错字。 I commit this change, so new commit B now comes right after A .我提交了这个更改,所以新的提交B现在紧跟在A之后。

Am I allowed to move the v1.0.0 tag to commit B , since I didn't make any breaking changes, and the code of my library is exactly the same as in commit A ?我是否允许将 v1.0.0 标记移动到提交B ,因为我没有进行任何重大更改,并且我的库的代码与提交A中的代码完全相同?

Or, do I need to include even such small changes in a follow-up patch , eg v1.0.1 instead?或者,我是否需要在后续补丁中包含如此小的更改,例如 v1.0.1?

Point 3 in SemVer 2.0 makes this pretty explicit: SemVer 2.0 中的第 3 点非常明确:

Once a versioned package has been released, the contents of that version MUST NOT be modified.版本化的 package 发布后,不得修改该版本的内容。 Any modifications MUST be released as a new version.任何修改都必须作为新版本发布。

Note that SemVer has no regards for your source code management tools, only the released package .请注意,SemVer 不考虑您的源代码管理工具,只考虑发布的 package If the released package has changed, then it is a new version.如果发布的 package 发生了变化,那么它是一个新版本。 So, if your documentation ships as part of the released package, fixing it is a change to the package.因此,如果您的文档作为已发布的 package 的一部分发布,则修复它是对 package 的更改。

On a practical note, as soon as you have shared a tag, or a labelled release, people who have downloaded that release may make explicit assumptions, such as that a SHA hash of its contents will match each time they download it, or that a mirror of your git repository won't have to overwrite already-fetched tags.实际上,一旦您共享了标签或带标签的版本,下载该版本的人可能会做出明确的假设,例如每次下载时其内容的 SHA hash 都会匹配,或者git 存储库的镜像不必覆盖已获取的标签。

Generally, SemVer treats version numbers as "cheap" - keeping things consistent and predictable is more important than any emotional attachment you might have to low numbers, and a version number like "54.23.13" is perfectly fine.一般来说,SemVer 将版本号视为“便宜”——保持一致和可预测比您可能对低数字产生的任何情感依恋更重要,并且像“54.23.13”这样的版本号非常好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM