Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion atlas.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Package
version = "0.9.1"
version = "0.9.2"
author = "Araq"
description = "Atlas is a simple package cloner tool. It manages an isolated project."
license = "MIT"
Expand Down
5 changes: 5 additions & 0 deletions src/basic/versions.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# distribution, for details about the copyright.
#

import std / [strutils, parseutils, algorithm, jsonutils, hashes]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-version-2-0 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / macos-arm64-nim-version-2-0 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-version-2-2 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-version-2-2 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-version-2-0 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-version-2-2 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-version-2-2 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / macos-arm64-nim-version-2-2 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-version-2-0 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-version-2-0 (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'jsonutils' [UnusedImport]

Check warning on line 9 in src/basic/versions.nim

View workflow job for this annotation

GitHub Actions / macos-arm64-nim-devel (master)

imported and not used: 'jsonutils' [UnusedImport]
import std / json

type
Expand Down Expand Up @@ -265,7 +265,10 @@

proc parseVersionInterval*(s: string; start: int; err: var bool): VersionInterval =
var i = start
# Skip whitespace and an optional '@' marker before the version spec
while i < s.len and s[i] in Whitespace: inc i
if "@" in s:
raise newException(ValueError, "@ is not allowed in version intervals, got: " & s)
result = VersionInterval(a: VersionReq(r: verAny, v: Version""))
if i < s.len:
case s[i]
Expand Down Expand Up @@ -351,6 +354,8 @@
result = matches(pattern.a, v)

proc extractRequirementName*(req: string): (string, seq[string], int) =
if "@" in req:
raise newException(ValueError, "@ is not allowed in version intervals, got: " & req)
const verChars = {'#', '<', '=', '>', '['}
var i = 0
while i < req.len and req[i] notin verChars + Whitespace:
Expand Down
38 changes: 21 additions & 17 deletions src/dependencies.nim
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,27 @@ proc addRelease(
nc: var NimbleContext;
pkg: Package,
vtag: VersionTag
): PackageVersion =
): bool =
var pkgver = vtag.toPkgVer()
trace pkg.url.projectName, "Adding Nimble version:", $vtag
let release = nc.processNimbleRelease(pkg, vtag)

if vtag.v.string == "":
pkgver.vtag.v = release.version
trace pkg.url.projectName, "updating release tag information:", $pkgver.vtag
elif release.version.string == "":
warn pkg.url.projectName, "nimble file missing version information:", $pkgver.vtag
release.version = vtag.version
elif vtag.v != release.version and not pkg.isRoot:
info pkg.url.projectName, "version mismatch between version tag:", $vtag.v, "and nimble version:", $release.version

versions.add((pkgver, release))

result = pkgver
try:
let release = nc.processNimbleRelease(pkg, vtag)

if vtag.v.string == "":
pkgver.vtag.v = release.version
trace pkg.url.projectName, "updating release tag information:", $pkgver.vtag
elif release.version.string == "":
warn pkg.url.projectName, "nimble file missing version information:", $pkgver.vtag
release.version = vtag.version
elif vtag.v != release.version and not pkg.isRoot:
info pkg.url.projectName, "version mismatch between version tag:", $vtag.v, "and nimble version:", $release.version

versions.add((pkgver, release))

result = true
except CatchableError as e:
error pkg.url.projectName, "addRelease error processing nimble release:", $vtag, "error:", $e.msg
return false

proc traverseDependency*(
nc: var NimbleContext;
Expand Down Expand Up @@ -238,8 +242,8 @@ proc traverseDependency*(
if not uniqueCommits.containsOrIncl(tag.c):
# trace pkg.url.projectName, "traverseDependency adding nimble commit:", $tag
var vers: seq[(PackageVersion, NimbleRelease)]
let pver = vers.addRelease(nc, pkg, tag)
if not nimbleVersions.containsOrIncl(pver.vtag.v):
let added = vers.addRelease(nc, pkg, tag)
if added and not nimbleVersions.containsOrIncl(vers[0][0].vtag.v):
versions.add(vers)
else:
error pkg.url.projectName, "traverseDependency skipping nimble commit:", $tag, "uniqueCommits:", $(tag.c in uniqueCommits), "nimbleVersions:", $(tag.v in nimbleVersions)
Expand Down
34 changes: 34 additions & 0 deletions tests/trequires_at_marker.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import std/[unittest]
import basic/versions

suite "requires @ parsing":
test "name without @ for version constraint":
let req = "mcu_utils@ >= 0.1.0"
let (name, feats, idx) = extractRequirementName(req)
check name == "mcu_utils"
check feats.len == 0
var err = false
let iv = parseVersionInterval(req, idx, err)
check not err
check $iv == ">= 0.1.0"

test "name without @ for #head":
let req = "mcu_utils@#head"
let (name, feats, idx) = extractRequirementName(req)
check name == "mcu_utils"
check feats.len == 0
var err = false
let iv = parseVersionInterval(req, idx, err)
check not err
check $iv == "#head"

test "url without trailing @ in name":
let req = "https://github.com/EmbeddedNim/mcu_utils@ >= 0.2.0"
let (name, feats, idx) = extractRequirementName(req)
check name == "https://github.com/EmbeddedNim/mcu_utils"
check feats.len == 0
var err = false
let iv = parseVersionInterval(req, idx, err)
check not err
check $iv == ">= 0.2.0"

Loading