Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1777f5b

Browse files
vsavkinFrozenPandaz
authored andcommittedAug 13, 2020
fix(core): remove deleted files from git-hashers result
1 parent d021876 commit 1777f5b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed
 

‎packages/workspace/src/core/hasher/git-hasher.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,36 @@ function gitLsTree(path: string): Map<string, string> {
8080
return parseGitLsTree(spawnProcess('git', ['ls-tree', 'HEAD', '-r'], path));
8181
}
8282

83-
function gitStatus(path: string): Map<string, string> {
83+
function gitStatus(
84+
path: string
85+
): { status: Map<string, string>; deletedFiles: string[] } {
86+
const deletedFiles: string[] = [];
8487
const filesToHash: string[] = [];
8588
parseGitStatus(
8689
spawnProcess('git', ['status', '-s', '-u', '.'], path)
8790
).forEach((changeType: string, filename: string) => {
8891
if (changeType !== 'D') {
8992
filesToHash.push(filename);
93+
} else {
94+
deletedFiles.push(filename);
9095
}
9196
});
92-
return getGitHashForFiles(filesToHash, path);
97+
const status = getGitHashForFiles(filesToHash, path);
98+
return { deletedFiles, status };
9399
}
94100

95101
export function getFileHashes(path: string): Map<string, string> {
96102
const res = new Map<string, string>();
97103

98104
try {
105+
const { deletedFiles, status } = gitStatus(path);
99106
const m1 = gitLsTree(path);
100107
m1.forEach((hash: string, filename: string) => {
101-
res.set(`${path}/${filename}`, hash);
108+
if (deletedFiles.indexOf(filename) === -1) {
109+
res.set(`${path}/${filename}`, hash);
110+
}
102111
});
103-
const m2 = gitStatus(path);
104-
m2.forEach((hash: string, filename: string) => {
112+
status.forEach((hash: string, filename: string) => {
105113
res.set(`${path}/${filename}`, hash);
106114
});
107115
return res;

0 commit comments

Comments
 (0)
Please sign in to comment.