-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Song Song Li <[email protected]>
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
layout: post | ||
title: 语义版本控制 | ||
date: 2023-12-28 00:12:05 | ||
--- | ||
|
||
语义化版本控制(Semantic Versioning),通常表示为:主版本号.次版本号.修订号,即 MAJOR.MINOR.PATCH。下面是每个组成部分的含义和例子: | ||
|
||
- MAJOR版本:当你做了不兼容的API更改,即那些会破坏现有用户的代码更改时,你需要增加主版本号。例如,从 1.6.3 更新到 2.0.0 表示有重大更改,现有的用户可能需要修改他们的代码才能适应新版本。 | ||
|
||
- MINOR版本:当你添加了新功能,但是以向后兼容的方式,即不会破坏现有功能时,你需要增加次版本号。例如,从 1.6.3 更新到 1.7.0 表示添加了新功能,但是现有的用户代码不会受影响。 | ||
|
||
- PATCH版本:当你进行了向后兼容的错误修复,即修复了一些小错误但没有添加新功能或者破坏现有功能时,你需要增加修订号。例如,从 1.6.3 更新到 1.6.4 通常表示修复了软件中的一些bug。 | ||
|
||
例如: | ||
|
||
- 假设一个开源库有一个函数 getUser(id),它返回一个用户对象。如果这个函数被改成 getUser(username),这是一个MAJOR版本变化,因为它改变了函数的使用方式。 | ||
|
||
- 如果在不改变 getUser(id) 的同时,库中添加了一个新的函数 getUserByEmail(email),这是一个MINOR版本变化,因为它添加了新功能,但没有破坏旧的API。 | ||
|
||
- 如果发现 getUser(id) 有时返回错误的用户,然后这个问题被修复了,这是一个PATCH版本的变化,因为它仅仅是修复了现有功能的一个bug。 |