History

Add Git action modal with custom commit message support

- Add a Git action confirmation modal with live commit/push/PR progress states - Accept optional `commitMessage` input and skip AI message generation when provided - Expand server and contracts tests for custom commit message handling

Julius Marminge committed 9 months ago

Commit 36bc85f1 parent 3c939e85 files · +538 −44Browse files

Showing the changes to apps/server/src/gitManager.test.ts (1 of 5 files). Show all

Unified · Split

apps/server/src/gitManager.test.ts+34−0
@@ -248,6 +248,40 @@ describe("GitManager", () => { · 247 unmodified lines
248 );248 );
249 });249 });
250 250
251 it("uses custom commit message when provided", async () => {
252 const repoDir = makeTempDir("t3code-git-manager-");
253 await initRepo(repoDir);
254 fs.writeFileSync(path.join(repoDir, "README.md"), "hello\ncustom\n");
255 let generatedCount = 0;
256
257 const manager = new GitManager({
258 textGenerator: createTextGenerator({
259 generateCommitMessage: async () => {
260 generatedCount += 1;
261 return {
262 subject: "this should not be used",
263 body: "",
264 };
265 },
266 }),
267 });
268 const result = await manager.runStackedAction({
269 cwd: repoDir,
270 action: "commit",
271 commitMessage: "feat: custom summary line\n\n- details from user",
272 });
273
274 expect(result.commit.status).toBe("created");
275 expect(result.commit.subject).toBe("feat: custom summary line");
276 expect(generatedCount).toBe(0);
277 expect(await runGitStdout(repoDir, ["log", "-1", "--pretty=%s"])).toBe(
278 "feat: custom summary line",
279 );
280 expect(await runGitStdout(repoDir, ["log", "-1", "--pretty=%b"])).toContain(
281 "- details from user",
282 );
283 });
284
251 it("skips commit when there are no uncommitted changes", async () => {285 it("skips commit when there are no uncommitted changes", async () => {
252 const repoDir = makeTempDir("t3code-git-manager-");286 const repoDir = makeTempDir("t3code-git-manager-");
253 await initRepo(repoDir);287 await initRepo(repoDir);