summary refs log tree commit diff stats
path: root/tools/deps.nim
diff options
context:
space:
mode:
authoralaviss <leorize+oss@disroot.org>2020-10-02 11:52:20 -0500
committerGitHub <noreply@github.com>2020-10-02 18:52:20 +0200
commite3eae3f7c7e9db6962f30dcb84657f3269ff3476 (patch)
treeb6123354a68b5530473e41f8b83a055976b786ef /tools/deps.nim
parentff70ff529d23d5ca6abe0e16d815172dd24a9dd1 (diff)
downloadNim-e3eae3f7c7e9db6962f30dcb84657f3269ff3476.tar.gz
tools/deps: fix git dir check (#15470)
On Windows, a successful call will have a trailing newline appended, so
strip that away before doing any checks.
Diffstat (limited to 'tools/deps.nim')
-rw-r--r--tools/deps.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/deps.nim b/tools/deps.nim
index 394dc0d25..b238f12ed 100644
--- a/tools/deps.nim
+++ b/tools/deps.nim
@@ -1,4 +1,4 @@
-import os, uri, strformat, osproc
+import os, uri, strformat, osproc, strutils
 
 proc exec(cmd: string) =
   echo "deps.cmd: " & cmd
@@ -14,7 +14,11 @@ proc isGitRepo(dir: string): bool =
   # Using this, we can verify whether a folder is a git repository by checking
   # whether the command success and if the output is empty.
   let (output, status) = execEx fmt"git -C {quoteShell(dir)} rev-parse --show-cdup"
-  result = status == 0 and output == ""
+  # On Windows there will be a trailing newline on success, remove it.
+  # The value of a successful call typically won't have a whitespace (it's
+  # usually a series of ../), so we know that it's safe to unconditionally
+  # remove trailing whitespaces from the result.
+  result = status == 0 and output.strip() == ""
 
 const commitHead* = "HEAD"