Fixed handling of versions with dashes in nimble pkgs (#6335)
This commit is contained in:
parent
cf28222d2c
commit
d8944b93cb
1 changed files with 20 additions and 9 deletions
|
|
@ -15,12 +15,6 @@ proc addPath*(path: string, info: TLineInfo) =
|
||||||
if not options.searchPaths.contains(path):
|
if not options.searchPaths.contains(path):
|
||||||
options.searchPaths.insert(path, 0)
|
options.searchPaths.insert(path, 0)
|
||||||
|
|
||||||
proc versionSplitPos(s: string): int =
|
|
||||||
result = s.len-2
|
|
||||||
#while result > 1 and s[result] in {'0'..'9', '.'}: dec result
|
|
||||||
while result > 1 and s[result] != '-': dec result
|
|
||||||
if s[result] != '-': result = s.len
|
|
||||||
|
|
||||||
type
|
type
|
||||||
Version = distinct string
|
Version = distinct string
|
||||||
|
|
||||||
|
|
@ -63,10 +57,27 @@ proc `<`(ver: Version, ver2: Version): bool =
|
||||||
else:
|
else:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
proc getPathVersion*(p: string): tuple[name, version: string] =
|
||||||
|
## Splits path ``p`` in the format ``/home/user/.nimble/pkgs/package-0.1``
|
||||||
|
## into ``(/home/user/.nimble/pkgs/package, 0.1)``
|
||||||
|
result.name = ""
|
||||||
|
result.version = ""
|
||||||
|
|
||||||
|
const specialSeparator = "-#"
|
||||||
|
var sepIdx = p.find(specialSeparator)
|
||||||
|
if sepIdx == -1:
|
||||||
|
sepIdx = p.rfind('-')
|
||||||
|
|
||||||
|
if sepIdx == -1:
|
||||||
|
result.name = p
|
||||||
|
return
|
||||||
|
|
||||||
|
result.name = p[0 .. sepIdx - 1]
|
||||||
|
result.version = p.substr(sepIdx + 1)
|
||||||
|
|
||||||
proc addPackage(packages: StringTableRef, p: string) =
|
proc addPackage(packages: StringTableRef, p: string) =
|
||||||
let x = versionSplitPos(p)
|
let (name, ver) = getPathVersion(p)
|
||||||
let name = p.substr(0, x-1)
|
let version = newVersion(ver)
|
||||||
let version = newVersion(if x < p.len: p.substr(x+1) else: "")
|
|
||||||
if packages.getOrDefault(name).newVersion < version or
|
if packages.getOrDefault(name).newVersion < version or
|
||||||
(not packages.hasKey(name)):
|
(not packages.hasKey(name)):
|
||||||
packages[name] = $version
|
packages[name] = $version
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue