Fixes #436. Develop clones HEAD and full history.

This commit is contained in:
Dominik Picheta 2018-09-02 01:11:50 +01:00
commit d606867da6
3 changed files with 21 additions and 8 deletions

View file

@ -1016,7 +1016,16 @@ proc develop(options: Options) =
let (meth, url, metadata) = getDownloadInfo(pv, options, true) let (meth, url, metadata) = getDownloadInfo(pv, options, true)
let subdir = metadata.getOrDefault("subdir") 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) developFromDir(downloadDir / subdir, options)
proc test(options: Options) = proc test(options: Options) =

View file

@ -42,17 +42,17 @@ proc doPull(meth: DownloadMethod, downloadDir: string) =
doCmd("hg pull") doCmd("hg pull")
proc doClone(meth: DownloadMethod, url, downloadDir: string, branch = "", proc doClone(meth: DownloadMethod, url, downloadDir: string, branch = "",
tip = true) = onlyTip = true) =
case meth case meth
of DownloadMethod.git: of DownloadMethod.git:
let let
depthArg = if tip: "--depth 1 " else: "" depthArg = if onlyTip: "--depth 1 " else: ""
branchArg = if branch == "": "" else: "-b " & branch & " " branchArg = if branch == "": "" else: "-b " & branch & " "
doCmd("git clone --recursive " & depthArg & branchArg & url & doCmd("git clone --recursive " & depthArg & branchArg & url &
" " & downloadDir) " " & downloadDir)
of DownloadMethod.hg: of DownloadMethod.hg:
let let
tipArg = if tip: "-r tip " else: "" tipArg = if onlyTip: "-r tip " else: ""
branchArg = if branch == "": "" else: "-b " & branch & " " branchArg = if branch == "": "" else: "-b " & branch & " "
doCmd("hg clone " & tipArg & branchArg & url & " " & downloadDir) doCmd("hg clone " & tipArg & branchArg & url & " " & downloadDir)
@ -171,10 +171,11 @@ proc doDownload(url: string, downloadDir: string, verRange: VersionRange,
if verRange.kind == verSpecial: if verRange.kind == verSpecial:
# We want a specific commit/branch/tag here. # We want a specific commit/branch/tag here.
if verRange.spe == getHeadName(downMethod): if verRange.spe == getHeadName(downMethod):
doClone(downMethod, url, downloadDir) # Grab HEAD. # Grab HEAD.
doClone(downMethod, url, downloadDir, onlyTip = not options.forceFullClone)
else: else:
# Grab the full repo. # 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. # Then perform a checkout operation to get the specified branch/commit.
# `spe` starts with '#', trim it. # `spe` starts with '#', trim it.
doAssert(($verRange.spe)[0] == '#') doAssert(($verRange.spe)[0] == '#')
@ -191,12 +192,13 @@ proc doDownload(url: string, downloadDir: string, verRange: VersionRange,
getLatestByTag: getLatestByTag:
display("Cloning", "latest tagged version: " & latest.tag, display("Cloning", "latest tagged version: " & latest.tag,
priority = MediumPriority) priority = MediumPriority)
doClone(downMethod, url, downloadDir, latest.tag) doClone(downMethod, url, downloadDir, latest.tag,
onlyTip = not options.forceFullClone)
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.
of DownloadMethod.hg: of DownloadMethod.hg:
doClone(downMethod, url, downloadDir) doClone(downMethod, url, downloadDir, onlyTip = not options.forceFullClone)
result = getHeadName(downMethod) result = getHeadName(downMethod)
let versions = getTagsList(downloadDir, downMethod).getVersionList() let versions = getTagsList(downloadDir, downMethod).getVersionList()

View file

@ -22,6 +22,8 @@ type
showVersion*: bool showVersion*: bool
noColor*: bool noColor*: bool
disableValidation*: bool disableValidation*: bool
## Whether packages' repos should always be downloaded with their history.
forceFullClone*: bool
ActionType* = enum ActionType* = enum
actionNil, actionRefresh, actionInit, actionDump, actionPublish, actionNil, actionRefresh, actionInit, actionDump, actionPublish,