Skip to content

Commit 562f49b

Browse files
authored
fix(core): use git restore to remove vote files (#25)
There was an assumption that all vote files would be in the same folder, but that doesn't have to be the case. Instead we can use `git restore` to make sure all the changes are removed.
1 parent 89e6a26 commit 562f49b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

packages/core/src/countBallotsFromGit.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,23 @@ export default async function countFromGit({
239239
} finally {
240240
await fd.close();
241241
}
242-
await runChildProcessAsync(GIT_BIN, ["add", filepath], { spawnArgs });
243242

244243
// Remove all vote related files.
245-
await runChildProcessAsync(GIT_BIN, ["rm", "-rf", subPath], { spawnArgs });
244+
await runChildProcessAsync(
245+
GIT_BIN,
246+
[
247+
"restore",
248+
"--source",
249+
`${firstCommitRef}^`,
250+
"--staged",
251+
"--worktree",
252+
"--",
253+
".",
254+
],
255+
{ spawnArgs }
256+
);
257+
258+
await runChildProcessAsync(GIT_BIN, ["add", filepath], { spawnArgs });
246259

247260
await runChildProcessAsync(
248261
GIT_BIN,

0 commit comments

Comments
 (0)