From ffd56f89aefa95e35a1b89ded4ec45bd8500b7da Mon Sep 17 00:00:00 2001 From: Arthur Mialon Date: Thu, 2 Jan 2025 13:52:19 +0100 Subject: [PATCH] fix: make sure to add untracked files --- src/commands/push.ts | 1 + src/tools/git.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/commands/push.ts b/src/commands/push.ts index c5ffaf2..d3199a0 100644 --- a/src/commands/push.ts +++ b/src/commands/push.ts @@ -53,6 +53,7 @@ export default new Command() Deno.exit(0); } + await git.add(repo); await git.commit(repo, commitMessage); await git.push(repo, branch); diff --git a/src/tools/git.ts b/src/tools/git.ts index 720ba23..e7d1cbc 100644 --- a/src/tools/git.ts +++ b/src/tools/git.ts @@ -52,12 +52,29 @@ export const hasChange = async ( return !!Number(status.trim().length); }; +export const add = async ( + repository: string, +): Promise => { + const command = new Deno.Command("git", { + args: ["-C", repository, "add", "."], + stdout: "piped", + stderr: "piped", + }).spawn(); + + copy(readerFromStreamReader(command.stdout.getReader()), Deno.stdout); + copy(readerFromStreamReader(command.stderr.getReader()), Deno.stderr); + + const { success } = await command.status; + + return !!success; +}; + export const commit = async ( repository: string, message: string, ): Promise => { const command = new Deno.Command("git", { - args: ["-C", repository, "commit", "-am", message], + args: ["-C", repository, "commit", "-m", message], stdout: "piped", stderr: "piped", }).spawn();