Skip to content

Commit

Permalink
fix(vcs): error when stat-ing deleted file that's still in git index
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Jun 19, 2019
1 parent 1d02f13 commit 3c21ba4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion garden-service/src/vcs/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class GitHandler extends VcsHandler {
hash = await this.hashObject(resolvedPath) || ""
} catch (err) {
// 128 = File no longer exists
if (err.code !== 128) {
if (err.code !== 128 && err.code !== "ENOENT") {
throw err
}
}
Expand Down
13 changes: 12 additions & 1 deletion garden-service/test/unit/src/vcs/git.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai"
import * as tmp from "tmp-promise"
import { createFile, writeFile, realpath, mkdir } from "fs-extra"
import { createFile, writeFile, realpath, mkdir, remove } from "fs-extra"
import { join, resolve } from "path"

import { expectError } from "../../../helpers"
Expand Down Expand Up @@ -134,6 +134,17 @@ describe("GitHandler", () => {
])
})

it("should gracefully skip files that are deleted after having been committed", async () => {
const filePath = join(tmpPath, "my file.txt")
await createFile(filePath)
await git("add", filePath)
await git("commit", "-m", "foo")

await remove(filePath)

expect(await handler.getFiles(tmpPath)).to.eql([])
})

it("should work with untracked files with spaces in the name", async () => {
const filePath = join(tmpPath, "my file.txt")
await createFile(filePath)
Expand Down

0 comments on commit 3c21ba4

Please sign in to comment.