Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): every commit hook reports finishing with its real exit code #22939

MergedMarcoDotIO(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/22939/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 60 additions and 12 deletions.

x
0 of 2 viewed, 2 left
50 additions and 0 deletionsapps/server/src/vcs/GitVcsDriverCore.test.tsModified
View file
@@ -3874,6 +3874,56 @@
+ const commitWithHooks = (hooks: Record<string, string>) =>
+ Effect.gen(function* () {
+ const cwd = yield* makeTmpDir();
+ yield* initRepoWithCommit(cwd);
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ for (const [name, script] of Object.entries(hooks)) {
+ yield* writeTextFile(cwd, `.git/hooks/${name}`, `#!/bin/sh\n${script}\n`);
+ yield* fs.chmod(path.join(cwd, ".git/hooks", name), 0o755);
+ }
+ yield* writeTextFile(cwd, "a.txt", "a\n");
+ const events: string[] = [];
+ const result = yield* (yield* GitVcsDriver.GitVcsDriver)
+ .commit(cwd, "Add a", "", {
+ stage: { filePaths: ["a.txt"] },
+ progress: {
+ onHookStarted: (hookName) => Effect.sync(() => void events.push(`start ${hookName}`)),
+ onHookFinished: ({ hookName, exitCode }) =>
+ Effect.sync(() => void events.push(`finish ${hookName} ${exitCode}`)),
+ },
+ })
+ .pipe(Effect.result);
+ return { events, committed: Result.isSuccess(result) };
+ });
+​
+ it.effect("reports each commit hook finishing with its exit code", () =>