Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[features]: 语义版本控制(Semantic Versioning)模块 #45

Open
Sunrisepeak opened this issue Dec 7, 2024 · 3 comments
Open

[features]: 语义版本控制(Semantic Versioning)模块 #45

Sunrisepeak opened this issue Dec 7, 2024 · 3 comments
Assignees
Labels
feature | 功能 New feature or request

Comments

@Sunrisepeak
Copy link
Member

Features Describe | 功能描述

function parse(versionString)
    -- 解析版本字符串
end

-- 版本比较

function semvereq(v1, v2)
    -- 相等比较
end

function semvergt(v1, v2)
    -- 大于比较
end

function semverlt(v1, v2)
    -- 小于比较
end

Usage Scenario | 需求背景/使用场景

用于处理语义化的版本标识

lib5 = ">1.2.3"    # 大于 1.2.3
lib6 = ">=1.2.3"   # 大于等于 1.2.3
lib7 = "<2.0.0"    # 小于 2.0.0

Maybe Solutions | 可能的实现方案 - (if you are developer)

Additional context | 额外补充

@Sunrisepeak Sunrisepeak added the feature | 功能 New feature or request label Dec 7, 2024
@Sunrisepeak Sunrisepeak moved this to In progress in Xlings-Dev-Kanban Dec 7, 2024
@MoYingJi
Copy link
Collaborator

MoYingJi commented Dec 7, 2024

基本代码
目前在 core/installer/base/deps_version_parser.lua

@MoYingJi
Copy link
Collaborator

MoYingJi commented Dec 7, 2024

更新代码
新增了 -beta1 -alpha1 一类后缀的支持

@MoYingJi
Copy link
Collaborator

MoYingJi commented Dec 7, 2024

现在 parse_version 解析后的版本对象类似于这样
{ min = "1.0", max = nil, min_inclusive = true }
nil 为不限制 此时xxx_inclusive应为nil 但无论xxx_inclusive的值是什么都不影响意思
xxx_inclusive=true 表示包含某版本 若xxx不为nil那么此字段必不为nil

gen_deps 需要类似 { {a="version_str",b=">=1.0"}, {...} }这样的参数
输出 { a={...}, b={...} } 其中省略部分为上述解析后的版本对象

compare_version 的返回结果可以看测试代码
目前用 -1, 0, 1 表示 小于 等于 大于

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature | 功能 New feature or request
Projects
Status: In progress
Development

No branches or pull requests

2 participants