Skip to content

resolve issue #280 interactive commit fix: resolve commit suggestion issue - #290

Open
Aryanboii wants to merge 1 commit into
404-PF:mainfrom
Aryanboii:fix/issue-280-interactive-commit
Open

resolve issue #280 interactive commit fix: resolve commit suggestion issue#290
Aryanboii wants to merge 1 commit into
404-PF:mainfrom
Aryanboii:fix/issue-280-interactive-commit

Conversation

@Aryanboii

@Aryanboii Aryanboii commented Aug 30, 2026

Copy link
Copy Markdown

Summary

  • Fixed the interactive commit issue
  • Added/updated tests for the fix
  • Verified with npm run test

Fixes #280

Review in cubic

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 72ac4533-4f85-4576-8d41-65f5df3cfd2f


Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/commands/suggest.ts">

<violation number="1" location="src/commands/suggest.ts:391">
P3: The new staged-change guard is misindented (2-space indent and `} else {` at column 0 inside a 6-space nesting), so `npm run format:check` fails and the PR cannot pass the format gate. Reindent the block to match the surrounding nesting.</violation>

<violation number="2" location="src/commands/suggest.ts:391">
P2: The new `if (!diffResult.staged)` block and its closing `} else {` are indented at column 0 instead of inside the enclosing `if (shouldCommit)` block, breaking the repo's Prettier convention. `npx prettier src/commands/suggest.ts` reformats lines 391-396, and `npm run format:check` will fail on this file. Indent the block and closing brace to 8 spaces.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/commands/suggest.ts
Comment on lines +391 to +396
if (!diffResult.staged) {
outro(pc.red('Commit requires staged changes. Stage your changes with `git add` and try again.'));
return;
}
await acceptAndCommit(selected, config, diffResult.diff);
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new if (!diffResult.staged) block and its closing } else { are indented at column 0 instead of inside the enclosing if (shouldCommit) block, breaking the repo's Prettier convention. npx prettier src/commands/suggest.ts reformats lines 391-396, and npm run format:check will fail on this file. Indent the block and closing brace to 8 spaces.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/commands/suggest.ts, line 391:

<comment>The new `if (!diffResult.staged)` block and its closing `} else {` are indented at column 0 instead of inside the enclosing `if (shouldCommit)` block, breaking the repo's Prettier convention. `npx prettier src/commands/suggest.ts` reformats lines 391-396, and `npm run format:check` will fail on this file. Indent the block and closing brace to 8 spaces.</comment>

<file context>
@@ -388,8 +388,12 @@ export async function suggestCommand(
       if (shouldCommit) {
-        await acceptAndCommit(selected, config, diffResult.diff);
-      } else {
+  if (!diffResult.staged) {
+    outro(pc.red('Commit requires staged changes. Stage your changes with `git add` and try again.'));
+    return;
</file context>
Suggested change
if (!diffResult.staged) {
outro(pc.red('Commit requires staged changes. Stage your changes with `git add` and try again.'));
return;
}
await acceptAndCommit(selected, config, diffResult.diff);
} else {
if (!diffResult.staged) {
outro(pc.red('Commit requires staged changes. Stage your changes with `git add` and try again.'));
return;
}
await acceptAndCommit(selected, config, diffResult.diff);
} else {

Comment thread src/commands/suggest.ts
if (shouldCommit) {
await acceptAndCommit(selected, config, diffResult.diff);
} else {
if (!diffResult.staged) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new staged-change guard is misindented (2-space indent and } else { at column 0 inside a 6-space nesting), so npm run format:check fails and the PR cannot pass the format gate. Reindent the block to match the surrounding nesting.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/commands/suggest.ts, line 391:

<comment>The new staged-change guard is misindented (2-space indent and `} else {` at column 0 inside a 6-space nesting), so `npm run format:check` fails and the PR cannot pass the format gate. Reindent the block to match the surrounding nesting.</comment>

<file context>
@@ -388,8 +388,12 @@ export async function suggestCommand(
       if (shouldCommit) {
-        await acceptAndCommit(selected, config, diffResult.diff);
-      } else {
+  if (!diffResult.staged) {
+    outro(pc.red('Commit requires staged changes. Stage your changes with `git add` and try again.'));
+    return;
</file context>

@404-Page-Found 404-Page-Found left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cubic bot comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Interactive suggest --commit with only unstaged changes attempts commit on an empty index

2 participants