From dda0c39e34c6ed4750e45ab082c29bb49d90b158 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Tue, 3 Jan 2017 19:25:36 +0000 Subject: [PATCH] Fixes #304. --- src/nimblepkg/packageparser.nim | 14 ++++++++------ tests/tester.nim | 4 ++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/nimblepkg/packageparser.nim b/src/nimblepkg/packageparser.nim index f7e96e1..fef696b 100644 --- a/src/nimblepkg/packageparser.nim +++ b/src/nimblepkg/packageparser.nim @@ -290,12 +290,14 @@ proc readPackageInfo(nf: NimbleFile, options: Options, # By default specialVersion is the same as version. result.specialVersion = result.version - # The package directory name may include a "special" version - # (example #head). If so, it is given higher priority and therefore - # overwrites the .nimble file's version. - let version = parseVersionRange(minimalInfo.version) - if version.kind == verSpecial: - result.specialVersion = minimalInfo.version + # Only attempt to read a special version if `nf` is inside the $nimbleDir. + if nf.startsWith(options.getNimbleDir()): + # The package directory name may include a "special" version + # (example #head). If so, it is given higher priority and therefore + # overwrites the .nimble file's version. + let version = parseVersionRange(minimalInfo.version) + if version.kind == verSpecial: + result.specialVersion = minimalInfo.version if not result.isMinimal: options.pkgInfoCache[nf] = result diff --git a/tests/tester.nim b/tests/tester.nim index 41c27f9..78df424 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -42,6 +42,10 @@ proc inLines(lines: seq[string], line: string): bool = for i in lines: if line.normalize in i.normalize: return true +test "can distinguish package reading in nimbleDir vs. other dirs (#304)": + cd "issue304" / "package-test": + check execNimble("tasks").exitCode == QuitSuccess + test "can build with #head and versioned package (#289)": cd "issue289": check execNimble(["install", "-y"]).exitCode == QuitSuccess