Skip to content

Commit

Permalink
fix: make sure to add untracked files
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurMialon committed Jan 2, 2025
1 parent 82c45dd commit ffd56f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
19 changes: 18 additions & 1 deletion src/tools/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,29 @@ export const hasChange = async (
return !!Number(status.trim().length);
};

export const add = async (
repository: string,
): Promise<boolean> => {
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<boolean> => {
const command = new Deno.Command("git", {
args: ["-C", repository, "commit", "-am", message],
args: ["-C", repository, "commit", "-m", message],
stdout: "piped",
stderr: "piped",
}).spawn();
Expand Down

0 comments on commit ffd56f8

Please sign in to comment.