Skip to content

Commit

Permalink
Refactor confirm prompt and remove npx usage instructions from auto-g…
Browse files Browse the repository at this point in the history
…it-commit-message guide
  • Loading branch information
pelikhan committed Aug 30, 2024
1 parent 205a68a commit 5338c76
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions docs/src/content/docs/guides/auto-git-commit-message.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ let { stdout } = await host.exec("git", ["diff", "--cached"])
If no changes are staged, we ask the user if they want to stage all changes. If the user confirms, we stage all changes. Otherwise, we bail out.

```ts
const stage = await confirm({
message: "No staged changes. Stage all changes?",
default: true,
})
if (stage) {
await host.exec("git", ["add", "."])
stdout = (await host.exec("git", ["diff", "--cached"])).stdout
}
if (!stdout) cancel("no staged changes")
const stage = await confirm({
message: "No staged changes. Stage all changes?",
default: true,
})
if (stage) {
await host.exec("git", ["add", "."])
stdout = (await host.exec("git", ["diff", "--cached"])).stdout
}
if (!stdout) cancel("no staged changes")
```

We generate an initial commit message using the staged changes:
Expand Down Expand Up @@ -111,12 +111,6 @@ Since it uses the [@inquirer/prompts](https://www.npmjs.com/package/@inquirer/pr
npm install --save-dev @inquirer/prompts
```

If you are using [npx](https://docs.npmjs.com/cli/v10/commands/npx),

```bash
npx -p @inquirer/prompts -p genaiscript -- genaiscript run gcm
```

This command will run the script, and guide you through the process of generating and committing a Git message using AI, making your commits more informative and consistent.

You can wrap this command in a `gcm.sh` file or in your package `script` section in `package.json`:
Expand Down

0 comments on commit 5338c76

Please sign in to comment.