Skip to content
Open
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
9 changes: 7 additions & 2 deletions src/nimblepkg/vcstools.nim
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ proc getVcsTypeAndSpecialDirPath*(dir: Path): VcsTypeAndSpecialDirPath =
## The procedure uses a in memory cache to bypass multiple checks for the same
## directory in single run of Nimble.
##
## Raises a `NimbleError` in the case the directory `dir` does not exist.
## Returns `(vcsTypeNone, "")` when `dir` is empty (e.g. unresolvable package path).
## Raises a `NimbleError` when `dir` is non-empty but does not exist.

if getVcsTypeAndSpecialDirPathCache().hasKey(dir):
return getVcsTypeAndSpecialDirPathCache()[dir]

if dir == "":
return (vcsTypeNone, Path(""))

if not dir.dirExists:
raise nimbleError(dirDoesNotExistErrorMsg(dir))

Expand All @@ -121,7 +125,8 @@ proc getVcsTypeAndSpecialDirPath*(dir: Path): VcsTypeAndSpecialDirPath =

proc getVcsType*(dir: Path): VcsType =
## Returns VCS type of the given directory.
## Raises a `NimbleError` in the case the directory `dir` does not exist.
## Returns `vcsTypeNone` if `dir` is empty (e.g. unresolvable package path).
## Raises a `NimbleError` when `dir` is non-empty but does not exist.
dir.getVcsTypeAndSpecialDirPath.vcsType

proc git(path: Path): string =
Expand Down
Loading