git:// now replaced with https:// (configurable). Ref #86.

This commit is contained in:
Dominik Picheta 2015-12-29 14:37:10 +00:00
commit 2f57dd1b2a
3 changed files with 14 additions and 2 deletions

View file

@ -303,6 +303,9 @@ You can currently configure the following in this file:
a ``[PackageList]`` section named "official". Multiple URLs can be specified a ``[PackageList]`` section named "official". Multiple URLs can be specified
under each section, Nimble will try each in succession if under each section, Nimble will try each in succession if
downloading from the first fails. downloading from the first fails.
* ``cloneUsingHttps`` - Whether to replace any ``git://`` inside URLs with
``https://``.
**Default: true**
## Creating Packages ## Creating Packages

View file

@ -471,10 +471,15 @@ proc downloadPkg(url: string, verRange: VersionRange,
## which was downloaded. ## which was downloaded.
let downloadDir = (getNimbleTempDir() / getDownloadDirName(url, verRange)) let downloadDir = (getNimbleTempDir() / getDownloadDirName(url, verRange))
createDir(downloadDir) createDir(downloadDir)
echo("Downloading ", url, " into ", downloadDir, " using ", downMethod, "...") let modUrl =
if url.startsWith("git://") and options.config.cloneUsingHttps:
"https://" & url[6 .. ^1]
else: url
echo("Downloading ", modUrl, " into ", downloadDir, " using ",
downMethod, "...")
result = ( result = (
downloadDir, downloadDir,
doDownload(url, downloadDir, verRange, downMethod, options) doDownload(modUrl, downloadDir, verRange, downMethod, options)
) )
proc getDownloadInfo*(pv: PkgTuple, options: Options, proc getDownloadInfo*(pv: PkgTuple, options: Options,

View file

@ -9,6 +9,7 @@ type
nimbleDir*: string nimbleDir*: string
chcp*: bool # Whether to change the code page in .cmd files on Win. chcp*: bool # Whether to change the code page in .cmd files on Win.
packageLists*: Table[string, PackageList] ## URLs to packages.json files packageLists*: Table[string, PackageList] ## URLs to packages.json files
cloneUsingHttps*: bool # Whether to replace git:// for https://
PackageList* = object PackageList* = object
name*: string name*: string
@ -21,6 +22,7 @@ proc initConfig(): Config =
result.nimbleDir = getHomeDir() / ".babel" result.nimbleDir = getHomeDir() / ".babel"
result.chcp = true result.chcp = true
result.cloneUsingHttps = true
result.packageLists = initTable[string, PackageList]() result.packageLists = initTable[string, PackageList]()
let defaultPkgList = PackageList(name: "Official", urls: @[ let defaultPkgList = PackageList(name: "Official", urls: @[
@ -79,6 +81,8 @@ proc parseConfig*(): Config =
result.nimbleDir = e.value result.nimbleDir = e.value
of "chcp": of "chcp":
result.chcp = parseBool(e.value) result.chcp = parseBool(e.value)
of "cloneusinghttps":
result.cloneUsingHttps = parseBool(e.value)
of "name": of "name":
case currentSection.normalize case currentSection.normalize
of "packagelist": of "packagelist":