Repository navigation
Conversation
Member
|
在调整架构, 等待一起合入 |
nostalume
reviewed
Dec 16, 2024
| function parse_single_version(version_str) | ||
| function parse_single_version_range(version_str) | ||
| local version = {} | ||
| if version_str == "any" or version_str == "*" then |
Collaborator
There was a problem hiding this comment.
local Version = {}
Version.__index = Version
function Version:new(str)
local self = setmetatable({},Version}
self:parse(str)
return self
end
function Version:parse(str)
local pattern = (...)
local major,minor,patch,prerelease,build = str:match(pattern)
self.major = tonumber(major) or 0
self.minor = tonumber(minor) or 0
self.patch = tonumber(patch) or 0
self.prerelease = prerelease or ""
self.build = build or ""
end
function Version:compare(other)
if self.major ~= other.major then
return self.major - other.major
end
if self.minor ~= other.minor then
return self.minor - other.minor
end
if self.patch ~= other.patch then
return self.patch - other.patch
end
if self.prerelease ~= other.prerelease then
if self.prerelease == "" then
return 1
elseif other.prerelease == "" then
return -1
else
return self.prerelease < other.prerelease and 1 or -1
end
end
return 0
end
function Version:__lt(other)
return self:compare(other) < 0
end
function Version:__le(other)
return self:compare(other) <= 0
end
function Version:__eq(other)
return self:compare(other) == 0
end
function Version:__gt(other)
return self:compare(other) > 0
end
function Version:__ge(other)
return self:compare(other) >= 0
end
nostalume
reviewed
Dec 16, 2024
|
|
||
| -- 解析复合版本字符串到版本对象 | ||
| function parse_version(version_str) | ||
| function parse_version_ranges(version_str) |
Collaborator
There was a problem hiding this comment.
local Constraint = {}
Constraint.__index = Constraint
function Constraint:new(str)
local self = setmetatable({},Constraint)
self:parse(str)
return self
end
function Constraint:parse(str)
local pattern = (...)
local op,version_str = str:match(pattern)
self.op = op
self.version = Version:new(version_str)
end
function Constraint:include(version)
if self.operator == "*" then
return true -- "*" means any version
elseif self.operator == "<=" then
return version <= self.version
elseif self.operator == "<" then
return version < self.version
elseif self.operator == ">=" then
return version >= self.version
elseif self.operator == ">" then
return version > self.version
elseif self.operator == "=" then
return version == self.version
else
return false
end
end
Collaborator
There was a problem hiding this comment.
local Constraints = {}
Constraints.__index = Constraints
function Constraints:new(str)
local self = setmetatable({},Constraints)
self:parse(str)
return self
end
function Constraints:parse(str)
self.constraints = {}
for part in str:gmatch(...) do
table.insert(self.constraints,Constraint:new(part))
end
end
function Constraints:include(version)
for _,constraint in ipairs(self.constraints) do
if not constraint:include(verison) then
return false
end
end
return true
end
Sunrisepeak
added a commit
that referenced
this pull request
Oct 8, 2026
…dependent of SubOS scopes) The client was pinned to #47's fix commit on its PR branch; that branch is merged and gone, so the pin moves to the squash commit on libxpkg's main. Same code (the version bump to 0.0.62 is the only addition).
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这样大概可以了? #45