Skip to content

Commit

Permalink
tools/deps: fix git dir check (nim-lang#15470)
Browse files Browse the repository at this point in the history
On Windows, a successful call will have a trailing newline appended, so
strip that away before doing any checks.
  • Loading branch information
alaviss authored and mildred committed Jan 11, 2021
1 parent 32eb63b commit 903b5c9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/deps.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, uri, strformat, osproc
import os, uri, strformat, osproc, strutils

proc exec(cmd: string) =
echo "deps.cmd: " & cmd
Expand All @@ -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"

Expand Down

0 comments on commit 903b5c9

Please sign in to comment.