Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nimble develop --withDependencies #1120

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ proc listTasks(options: Options) =
let nimbleFile = findNimbleFile(getCurrentDir(), true)
nimscriptwrapper.listTasks(nimbleFile, options)

proc developAllDependencies(pkgInfo: PackageInfo, options: var Options)
proc developAllDependencies(pkgInfo: PackageInfo, options: var Options, topLevel = false)

proc saveLinkFile(pkgInfo: PackageInfo, options: Options) =
let
Expand All @@ -1226,7 +1226,7 @@ proc saveLinkFile(pkgInfo: PackageInfo, options: Options) =
writeFile(pkgLinkFilePath, pkgLinkFileContent)
displaySuccess(pkgLinkFileSavedMsg(pkgLinkFilePath))

proc developFromDir(pkgInfo: PackageInfo, options: var Options) =
proc developFromDir(pkgInfo: PackageInfo, options: var Options, topLevel = false) =
assert options.action.typ == actionDevelop,
"This procedure should be called only when executing develop sub-command."

Expand All @@ -1251,12 +1251,12 @@ proc developFromDir(pkgInfo: PackageInfo, options: var Options) =
createDir(optsCopy.getPkgsDir())
cd dir:
if options.action.withDependencies:
developAllDependencies(pkgInfo, optsCopy)
developAllDependencies(pkgInfo, optsCopy, topLevel = topLevel)
else:
discard processAllDependencies(pkgInfo, optsCopy)
else:
if options.action.withDependencies:
developAllDependencies(pkgInfo, options)
developAllDependencies(pkgInfo, options, topLevel = topLevel)
else:
# Dependencies need to be processed before the creation of the pkg dir.
discard processAllDependencies(pkgInfo, options)
Expand Down Expand Up @@ -1349,14 +1349,14 @@ proc developFreeDependencies(pkgInfo: PackageInfo,
let pkgInfo = installDevelopPackage(dep, options)
alreadyDownloaded.incl pkgInfo.metaData.url.removeTrailingGitString

proc developAllDependencies(pkgInfo: PackageInfo, options: var Options) =
proc developAllDependencies(pkgInfo: PackageInfo, options: var Options, topLevel = false) =
## Puts all dependencies of `pkgInfo` (including transitive ones) in develop
## mode by cloning their repositories.

var alreadyDownloadedDependencies {.global.}: HashSet[string]
alreadyDownloadedDependencies.incl pkgInfo.metaData.url.removeTrailingGitString

if pkgInfo.hasLockedDeps():
if pkgInfo.hasLockedDeps() and topLevel:
pkgInfo.developLockedDependencies(alreadyDownloadedDependencies, options)
else:
pkgInfo.developFreeDependencies(alreadyDownloadedDependencies, options)
Expand Down Expand Up @@ -1399,7 +1399,7 @@ proc develop(options: var Options) =
raise nimbleError(pathGivenButNoPkgsToDownloadMsg)

if currentDirPkgInfo.isLoaded and (not hasPackages) and (not hasDevActions):
developFromDir(currentDirPkgInfo, options)
developFromDir(currentDirPkgInfo, options, topLevel = true)

# Install each package.
for pkgTup in options.action.packages:
Expand Down
3 changes: 2 additions & 1 deletion src/nimblepkg/download.nim
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ proc cloneSpecificRevision(downloadMethod: DownloadMethod,
url, downloadDir: string,
vcsRevision: Sha1Hash) =
assert vcsRevision != notSetSha1Hash

display("Cloning", "revision: " & $vcsRevision, priority = MediumPriority)
case downloadMethod
of DownloadMethod.git:
Expand Down Expand Up @@ -417,7 +418,7 @@ proc doDownload(url, downloadDir: string, verRange: VersionRange,
result.vcsRevision = doDownloadTarball(url, downloadDir, "HEAD", true)
else:
# If no commits have been tagged on the repo we just clone HEAD.
doClone(downMethod, url, downloadDir) # Grab HEAD.
doClone(downMethod, url, downloadDir, onlyTip = not options.forceFullClone) # Grab HEAD.
of DownloadMethod.hg:
doClone(downMethod, url, downloadDir,
onlyTip = not options.forceFullClone)
Expand Down