Fix #110 : use '^' rather than '-' for list negative indexes
This commit is contained in:
parent
491b63cb5f
commit
87d6f908cc
5 changed files with 8 additions and 8 deletions
|
|
@ -171,7 +171,7 @@ proc parseCmdLine(): Options =
|
||||||
# Parse pkg@verRange
|
# Parse pkg@verRange
|
||||||
if '@' in key:
|
if '@' in key:
|
||||||
let i = find(key, '@')
|
let i = find(key, '@')
|
||||||
let pkgTup = (key[0 .. i-1], key[i+1 .. -1].parseVersionRange())
|
let pkgTup = (key[0 .. i-1], key[i+1 .. ^1].parseVersionRange())
|
||||||
result.action.packages.add(pkgTup)
|
result.action.packages.add(pkgTup)
|
||||||
else:
|
else:
|
||||||
result.action.packages.add((key, VersionRange(kind: verAny)))
|
result.action.packages.add((key, VersionRange(kind: verAny)))
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ proc getTagsListRemote*(url: string, meth: DownloadMethod): seq[string] =
|
||||||
for i in output.splitLines():
|
for i in output.splitLines():
|
||||||
if i == "": continue
|
if i == "": continue
|
||||||
let start = i.find("refs/tags/")+"refs/tags/".len
|
let start = i.find("refs/tags/")+"refs/tags/".len
|
||||||
let tag = i[start .. -1]
|
let tag = i[start .. ^1]
|
||||||
if not tag.endswith("^{}"): result.add(tag)
|
if not tag.endswith("^{}"): result.add(tag)
|
||||||
|
|
||||||
of DownloadMethod.hg:
|
of DownloadMethod.hg:
|
||||||
|
|
@ -118,7 +118,7 @@ proc getVersionList*(tags: seq[string]): Table[Version, string] =
|
||||||
if tag != "":
|
if tag != "":
|
||||||
let i = skipUntil(tag, Digits) # skip any chars before the version
|
let i = skipUntil(tag, Digits) # skip any chars before the version
|
||||||
# TODO: Better checking, tags can have any names. Add warnings and such.
|
# TODO: Better checking, tags can have any names. Add warnings and such.
|
||||||
result[newVersion(tag[i .. -1])] = tag
|
result[newVersion(tag[i .. ^1])] = tag
|
||||||
|
|
||||||
proc getDownloadMethod*(meth: string): DownloadMethod =
|
proc getDownloadMethod*(meth: string): DownloadMethod =
|
||||||
case meth
|
case meth
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,11 @@ proc parseRequires(req: string): PkgTuple =
|
||||||
if ' ' in req:
|
if ' ' in req:
|
||||||
var i = skipUntil(req, Whitespace)
|
var i = skipUntil(req, Whitespace)
|
||||||
result.name = req[0 .. i].strip
|
result.name = req[0 .. i].strip
|
||||||
result.ver = parseVersionRange(req[i .. -1])
|
result.ver = parseVersionRange(req[i .. ^1])
|
||||||
elif '#' in req:
|
elif '#' in req:
|
||||||
var i = skipUntil(req, {'#'})
|
var i = skipUntil(req, {'#'})
|
||||||
result.name = req[0 .. i-1]
|
result.name = req[0 .. i-1]
|
||||||
result.ver = parseVersionRange(req[i .. -1])
|
result.ver = parseVersionRange(req[i .. ^1])
|
||||||
else:
|
else:
|
||||||
result.name = req.strip
|
result.name = req.strip
|
||||||
result.ver = VersionRange(kind: verAny)
|
result.ver = VersionRange(kind: verAny)
|
||||||
|
|
@ -339,7 +339,7 @@ proc getNameVersion*(pkgpath: string): tuple[name, version: string] =
|
||||||
for i in countdown(tail.len-1, 0):
|
for i in countdown(tail.len-1, 0):
|
||||||
if tail[i] == '-':
|
if tail[i] == '-':
|
||||||
result.name = tail[0 .. i-1]
|
result.name = tail[0 .. i-1]
|
||||||
result.version = tail[i+1 .. -1]
|
result.version = tail[i+1 .. ^1]
|
||||||
break
|
break
|
||||||
|
|
||||||
proc echoPackage*(pkg: Package) =
|
proc echoPackage*(pkg: Package) =
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ proc changeRoot*(origRoot, newRoot, path: string): string =
|
||||||
## path: /home/dom/bar/blah/2/foo.txt
|
## path: /home/dom/bar/blah/2/foo.txt
|
||||||
## Return value -> /home/test/bar/blah/2/foo.txt
|
## Return value -> /home/test/bar/blah/2/foo.txt
|
||||||
if path.startsWith(origRoot):
|
if path.startsWith(origRoot):
|
||||||
return newRoot / path[origRoot.len .. -1]
|
return newRoot / path[origRoot.len .. ^1]
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"Cannot change root of path: Path does not begin with original root.")
|
"Cannot change root of path: Path does not begin with original root.")
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ proc parseVersionRange*(s: string): VersionRange =
|
||||||
new(result)
|
new(result)
|
||||||
if s[0] == '#':
|
if s[0] == '#':
|
||||||
result.kind = verSpecial
|
result.kind = verSpecial
|
||||||
result.spe = s[1 .. -1].Special
|
result.spe = s[1 .. ^1].Special
|
||||||
return
|
return
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue