Skip to content

Commit b9ce879

Browse files
authored
Merge pull request #14 from vavasilva/fix/use-only-staged-files
fix: use only staged files by default, add --all flag
2 parents dd44753 + a275e81 commit b9ce879

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,13 @@ export GROQ_API_KEY="your-api-key"
288288
## Usage
289289

290290
```bash
291-
# Basic: stage + generate + confirm + commit
292-
git add .
291+
# Basic: stage files + generate + confirm + commit
292+
git add file1.ts file2.ts
293293
git-commit-ai
294294

295+
# Stage all changes and commit
296+
git-commit-ai --all
297+
295298
# Auto-commit without confirmation
296299
git add .
297300
git-commit-ai -y
@@ -300,6 +303,9 @@ git-commit-ai -y
300303
git add .
301304
git-commit-ai --push
302305

306+
# Stage all changes and commit (equivalent to git add . && git-commit-ai)
307+
git-commit-ai --all
308+
303309
# Commit each modified file separately
304310
git-commit-ai --individual
305311

@@ -454,6 +460,7 @@ ignore_patterns = ["dist/*", "*.generated.ts"]
454460

455461
| Option | Description |
456462
|--------|-------------|
463+
| `-a, --all` | Stage all changes before committing |
457464
| `-p, --push` | Push after commit |
458465
| `-y, --yes` | Skip confirmation |
459466
| `-i, --individual` | Commit files individually |

src/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ export function createProgram(): Command {
409409
.option("--issue <ref>", "Reference an issue (e.g., 123 or #123)")
410410
.option("--breaking", "Mark as breaking change (adds ! to type)")
411411
.option("--co-author <author>", "Add co-author (can be used multiple times)", (val: string, prev: string[]) => prev.concat([val]), [] as string[])
412+
.option("-a, --all", "Stage all changes before committing")
412413
.action(async (options) => {
413414
if (options.debug) {
414415
enableDebug();
@@ -537,8 +538,8 @@ export function createProgram(): Command {
537538
coAuthors: options.coAuthor,
538539
};
539540

540-
// Don't stage files if amending
541-
if (!options.amend) {
541+
// Stage all files only if --all flag is used
542+
if (options.all && !options.amend) {
542543
addFiles(".");
543544
}
544545

0 commit comments

Comments
 (0)