diff --git a/src/nimble.nim b/src/nimble.nim index 49232f8..2c58030 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -1016,7 +1016,16 @@ proc develop(options: Options) = let (meth, url, metadata) = getDownloadInfo(pv, options, true) let subdir = metadata.getOrDefault("subdir") - discard downloadPkg(url, pv.ver, meth, subdir, options, downloadDir) + + # Download the HEAD and make sure the full history is downloaded. + let ver = + if pv.ver.kind == verAny: + parseVersionRange("#head") + else: + pv.ver + var options = options + options.forceFullClone = true + discard downloadPkg(url, ver, meth, subdir, options, downloadDir) developFromDir(downloadDir / subdir, options) proc test(options: Options) = diff --git a/src/nimblepkg/download.nim b/src/nimblepkg/download.nim index 226fe27..f8954e9 100644 --- a/src/nimblepkg/download.nim +++ b/src/nimblepkg/download.nim @@ -42,17 +42,17 @@ proc doPull(meth: DownloadMethod, downloadDir: string) = doCmd("hg pull") proc doClone(meth: DownloadMethod, url, downloadDir: string, branch = "", - tip = true) = + onlyTip = true) = case meth of DownloadMethod.git: let - depthArg = if tip: "--depth 1 " else: "" + depthArg = if onlyTip: "--depth 1 " else: "" branchArg = if branch == "": "" else: "-b " & branch & " " doCmd("git clone --recursive " & depthArg & branchArg & url & " " & downloadDir) of DownloadMethod.hg: let - tipArg = if tip: "-r tip " else: "" + tipArg = if onlyTip: "-r tip " else: "" branchArg = if branch == "": "" else: "-b " & branch & " " doCmd("hg clone " & tipArg & branchArg & url & " " & downloadDir) @@ -171,10 +171,11 @@ proc doDownload(url: string, downloadDir: string, verRange: VersionRange, if verRange.kind == verSpecial: # We want a specific commit/branch/tag here. if verRange.spe == getHeadName(downMethod): - doClone(downMethod, url, downloadDir) # Grab HEAD. + # Grab HEAD. + doClone(downMethod, url, downloadDir, onlyTip = not options.forceFullClone) else: # Grab the full repo. - doClone(downMethod, url, downloadDir, tip = false) + doClone(downMethod, url, downloadDir, onlyTip = false) # Then perform a checkout operation to get the specified branch/commit. # `spe` starts with '#', trim it. doAssert(($verRange.spe)[0] == '#') @@ -191,12 +192,13 @@ proc doDownload(url: string, downloadDir: string, verRange: VersionRange, getLatestByTag: display("Cloning", "latest tagged version: " & latest.tag, priority = MediumPriority) - doClone(downMethod, url, downloadDir, latest.tag) + doClone(downMethod, url, downloadDir, latest.tag, + onlyTip = not options.forceFullClone) else: # If no commits have been tagged on the repo we just clone HEAD. doClone(downMethod, url, downloadDir) # Grab HEAD. of DownloadMethod.hg: - doClone(downMethod, url, downloadDir) + doClone(downMethod, url, downloadDir, onlyTip = not options.forceFullClone) result = getHeadName(downMethod) let versions = getTagsList(downloadDir, downMethod).getVersionList() diff --git a/src/nimblepkg/options.nim b/src/nimblepkg/options.nim index ac9e0ae..a0e56b4 100644 --- a/src/nimblepkg/options.nim +++ b/src/nimblepkg/options.nim @@ -22,6 +22,8 @@ type showVersion*: bool noColor*: bool disableValidation*: bool + ## Whether packages' repos should always be downloaded with their history. + forceFullClone*: bool ActionType* = enum actionNil, actionRefresh, actionInit, actionDump, actionPublish,