Fixes #22
This commit is contained in:
parent
7e2d46a52c
commit
f350899a44
1 changed files with 15 additions and 14 deletions
29
download.nim
29
download.nim
|
|
@ -131,20 +131,21 @@ proc doDownload*(url: string, downloadDir: string, verRange: PVersionRange,
|
||||||
var latest = findLatest(verRange, versions)
|
var latest = findLatest(verRange, versions)
|
||||||
## Note: HEAD is not used when verRange.kind is verAny. This is
|
## Note: HEAD is not used when verRange.kind is verAny. This is
|
||||||
## intended behaviour, the latest tagged version will be used in this case.
|
## intended behaviour, the latest tagged version will be used in this case.
|
||||||
if latest.tag != "":
|
|
||||||
meth
|
# If no tagged versions satisfy our range latest.tag will be "".
|
||||||
else:
|
# We still clone in that scenario because we want to try HEAD in that case.
|
||||||
raise newException(EBabel,
|
# https://github.com/nimrod-code/babel/issues/22
|
||||||
"Could not find a version which fits the specified range: " & $verRange)
|
meth
|
||||||
|
|
||||||
proc verifyHead() =
|
proc verifyClone() =
|
||||||
## Makes sure that HEAD satisfies the requested version range.
|
## Makes sure that the downloaded package's version satisfies the requested
|
||||||
|
## version range.
|
||||||
let pkginfo = getPkgInfo(downloadDir)
|
let pkginfo = getPkgInfo(downloadDir)
|
||||||
if pkginfo.version.newVersion notin verRange:
|
if pkginfo.version.newVersion notin verRange:
|
||||||
raise newException(EBabel,
|
raise newException(EBabel,
|
||||||
"No versions of " & url &
|
"Downloaded package's version does not satisfy requested version " &
|
||||||
" exist (this usually means that `git tag` returned nothing)." &
|
"range: wanted $1 got $2." %
|
||||||
"Git HEAD also does not satisfy version range: " & $verRange)
|
[$verRange, $pkginfo.version])
|
||||||
|
|
||||||
removeDir(downloadDir)
|
removeDir(downloadDir)
|
||||||
if verRange.kind == verSpecial:
|
if verRange.kind == verSpecial:
|
||||||
|
|
@ -170,8 +171,8 @@ proc doDownload*(url: string, downloadDir: string, verRange: PVersionRange,
|
||||||
else:
|
else:
|
||||||
# If no commits have been tagged on the repo we just clone HEAD.
|
# If no commits have been tagged on the repo we just clone HEAD.
|
||||||
doClone(downMethod, url, downloadDir) # Grab HEAD.
|
doClone(downMethod, url, downloadDir) # Grab HEAD.
|
||||||
if verRange.kind != verAny:
|
|
||||||
verifyHead()
|
verifyClone()
|
||||||
of TDownloadMethod.Hg:
|
of TDownloadMethod.Hg:
|
||||||
doClone(downMethod, url, downloadDir)
|
doClone(downMethod, url, downloadDir)
|
||||||
let versions = getTagsList(downloadDir, downMethod).getVersionList()
|
let versions = getTagsList(downloadDir, downMethod).getVersionList()
|
||||||
|
|
@ -180,8 +181,8 @@ proc doDownload*(url: string, downloadDir: string, verRange: PVersionRange,
|
||||||
getLatestByTag:
|
getLatestByTag:
|
||||||
echo("Switching to latest tagged version: ", latest.tag)
|
echo("Switching to latest tagged version: ", latest.tag)
|
||||||
doCheckout(downMethod, downloadDir, latest.tag)
|
doCheckout(downMethod, downloadDir, latest.tag)
|
||||||
elif verRange.kind != verAny:
|
|
||||||
verifyHead()
|
verifyClone()
|
||||||
|
|
||||||
proc echoPackageVersions*(pkg: TPackage) =
|
proc echoPackageVersions*(pkg: TPackage) =
|
||||||
let downMethod = pkg.downloadMethod.getDownloadMethod()
|
let downMethod = pkg.downloadMethod.getDownloadMethod()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue