From 2f57dd1b2a8b76e17c7fa4001c114afbbb1320ed Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Tue, 29 Dec 2015 14:37:10 +0000 Subject: [PATCH] git:// now replaced with https:// (configurable). Ref #86. --- readme.markdown | 3 +++ src/nimble.nim | 9 +++++++-- src/nimblepkg/config.nim | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/readme.markdown b/readme.markdown index 82828ab..4afb915 100644 --- a/readme.markdown +++ b/readme.markdown @@ -303,6 +303,9 @@ You can currently configure the following in this file: a ``[PackageList]`` section named "official". Multiple URLs can be specified under each section, Nimble will try each in succession if downloading from the first fails. +* ``cloneUsingHttps`` - Whether to replace any ``git://`` inside URLs with + ``https://``. + **Default: true** ## Creating Packages diff --git a/src/nimble.nim b/src/nimble.nim index 24fefa1..2a3d585 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -471,10 +471,15 @@ proc downloadPkg(url: string, verRange: VersionRange, ## which was downloaded. let downloadDir = (getNimbleTempDir() / getDownloadDirName(url, verRange)) 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 = ( downloadDir, - doDownload(url, downloadDir, verRange, downMethod, options) + doDownload(modUrl, downloadDir, verRange, downMethod, options) ) proc getDownloadInfo*(pv: PkgTuple, options: Options, diff --git a/src/nimblepkg/config.nim b/src/nimblepkg/config.nim index e4a4ed1..967749f 100644 --- a/src/nimblepkg/config.nim +++ b/src/nimblepkg/config.nim @@ -9,6 +9,7 @@ type nimbleDir*: string chcp*: bool # Whether to change the code page in .cmd files on Win. packageLists*: Table[string, PackageList] ## URLs to packages.json files + cloneUsingHttps*: bool # Whether to replace git:// for https:// PackageList* = object name*: string @@ -21,6 +22,7 @@ proc initConfig(): Config = result.nimbleDir = getHomeDir() / ".babel" result.chcp = true + result.cloneUsingHttps = true result.packageLists = initTable[string, PackageList]() let defaultPkgList = PackageList(name: "Official", urls: @[ @@ -79,6 +81,8 @@ proc parseConfig*(): Config = result.nimbleDir = e.value of "chcp": result.chcp = parseBool(e.value) + of "cloneusinghttps": + result.cloneUsingHttps = parseBool(e.value) of "name": case currentSection.normalize of "packagelist":