diff options
Diffstat (limited to 'tools/deps.nim')
-rw-r--r-- | tools/deps.nim | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/deps.nim b/tools/deps.nim index 8ed95b59a..e43f7a2b4 100644 --- a/tools/deps.nim +++ b/tools/deps.nim @@ -1,6 +1,9 @@ -import os, uri, strformat, strutils +import std/[os, uri, strformat, strutils] import std/private/gitutils +when defined(nimPreviewSlimSystem): + import std/assertions + proc exec(cmd: string) = echo "deps.cmd: " & cmd let status = execShellCmd(cmd) @@ -22,14 +25,19 @@ proc cloneDependency*(destDirBase: string, url: string, commit = commitHead, let name = p.splitFile.name var destDir = destDirBase if appendRepoName: destDir = destDir / name - let destDir2 = destDir.quoteShell + let quotedDestDir = destDir.quoteShell if not dirExists(destDir): # note: old code used `destDir / .git` but that wouldn't prevent git clone # from failing - execRetry fmt"git clone -q {url} {destDir2}" + execRetry fmt"git clone -q {url} {quotedDestDir}" if isGitRepo(destDir): - execRetry fmt"git -C {destDir2} fetch -q" - exec fmt"git -C {destDir2} checkout -q {commit}" + let oldDir = getCurrentDir() + setCurrentDir(destDir) + try: + execRetry "git fetch -q" + exec fmt"git checkout -q {commit}" + finally: + setCurrentDir(oldDir) elif allowBundled: discard "this dependency was bundled with Nim, don't do anything" else: |