From d3bbc0534c70689a9cc58e68e94b0a6241a5e951 Mon Sep 17 00:00:00 2001 From: Emanuele Libralato Date: Mon, 29 Jul 2019 23:01:50 +0200 Subject: [PATCH] fix: exclude symlinks to directories from hashing --- garden-service/src/vcs/git.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/garden-service/src/vcs/git.ts b/garden-service/src/vcs/git.ts index 5b74b22f75..1fb0ddb7e1 100644 --- a/garden-service/src/vcs/git.ts +++ b/garden-service/src/vcs/git.ts @@ -126,7 +126,12 @@ export class GitHandler extends VcsHandler { // If we can't compute the hash, i.e. the file is gone, we filter it out below let hash = "" try { - hash = await this.hashObject(resolvedPath) || "" + // "git ls-files" returns a symlink even if it points to a directory. + // We filter symlinked directories out, since hashObject() will fail to + // process them. + if (!(await stat(resolvedPath)).isDirectory()) { + hash = await this.hashObject(resolvedPath) || "" + } } catch (err) { // 128 = File no longer exists if (err.code !== 128 && err.code !== "ENOENT") {