-
Notifications
You must be signed in to change notification settings - Fork 19
Feature: Auto Commit Flag #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Implements an `autoCommit` flag to automatically commit - changes after message generation.
WalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as CLI (cmd/cli/root.go)
participant Creator as CreateCommitMsg
User->>CLI: run "commit . [--dry-run] [--auto]"
CLI->>CLI: parse flags (dryRun, auto)
CLI->>Creator: CreateCommitMsg(dryRun, auto)
alt dry-run == true
Creator-->>CLI: generate message only (no git ops)
else if auto == true
Creator->>CLI: generate finalMessage
CLI->>CLI: start spinner
Creator->>shell: run `git commit -m finalMessage`
alt git success
Creator-->>CLI: commit output (success)
CLI->>User: print commit output
else git failure
Creator-->>CLI: commit output (error)
CLI->>User: print error and fail
end
else
Creator-->>CLI: generate message (interactive/default flow)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cmd/cli/root.go(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/cli/root.go (1)
cmd/cli/createMsg.go (1)
CreateCommitMsg(30-211)
🪛 GitHub Actions: Build and Release
cmd/cli/root.go
[error] 65-65: too many arguments in call to CreateCommitMsg.
🪛 GitHub Check: Build Go Binary (ubuntu-latest)
cmd/cli/root.go
[failure] 65-65:
too many arguments in call to CreateCommitMsg
| // Add --dry-run flag to the commit command | ||
| creatCommitMsg.Flags().Bool("dry-run", false, "Preview the prompt that would be sent to the LLM without making an API call") | ||
|
|
||
| // Add --auto flag to the commid command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in comment.
"commid" should be "commit".
Apply this diff:
- // Add --auto flag to the commid command
+ // Add --auto flag to the commit command📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Add --auto flag to the commid command | |
| // Add --auto flag to the commit command |
🤖 Prompt for AI Agents
In cmd/cli/root.go around line 84, the inline comment contains a typo: "commid"
should read "commit"; update the comment text to "Add --auto flag to the commit
command" (or equivalent) ensuring only the spelling is corrected and no other
code or formatting is changed.
|
hey can we remove the emojis |
|
Yea Im working on it |
|
Also, there was an issue in the groq folder, I fixed it, should I just include it in this PR? |
|
sure include that also |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
README.md(1 hunks)cmd/cli/createMsg.go(3 hunks)internal/groq/groq.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/groq/groq.go (1)
internal/http/client.go (1)
GetClient(32-40)
🔇 Additional comments (3)
internal/groq/groq.go (1)
11-11: LGTM! Good refactor for testability.The initialization of a package-level
httpClientininit()eliminates repeatedGetClient()calls and provides a clean override point for tests. Since*http.Clientis safe for concurrent use, storing it at package level is appropriate.Also applies to: 42-48, 91-91
cmd/cli/createMsg.go (2)
212-242: Auto-commit implementation looks solid.The implementation correctly:
- Gates auto-commit with
autoCommit && !dryRun(line 213)- Uses
exec.Commandwith separate arguments (safe from shell injection)- Sets working directory and environment for cross-platform compatibility (lines 224, 226)
- Captures and reports errors appropriately (lines 228-236)
- Only executes after
finalMessageis set through user acceptance (lines 143, 205-207)The
!dryRuncheck at line 213 is redundant from a pure control-flow perspective (since line 102 returns early ifdryRunis true), but it serves as good defensive programming and makes the intent explicit.Note: The implementation requires user acceptance in the interactive loop before auto-committing, which differs from the README documentation that suggests the interactive review is skipped entirely. This is actually safer behavior, but the documentation should be updated to match (see review comment on README.md).
30-30: Breaking-change verified: All calls to CreateCommitMsg now include the newautoCommitparameter; no further updates required.
| ### Auto Commit Mode | ||
|
|
||
| Automatically commit with the generated message without manual confirmation: | ||
|
|
||
| ```bash | ||
| commit . --auto | ||
| ``` | ||
|
|
||
| This will: | ||
| - Generate the commit message using your configured LLM | ||
| - Automatically execute `git commit` with the generated message | ||
| - Skip the interactive review and manual confirmation step | ||
|
|
||
| **Note**: The `--auto` flag cannot be combined with `--dry-run`. Dry run mode takes precedence and will only preview without committing. | ||
|
|
||
| **Platform Support**: Works on Linux, macOS, and Windows. | ||
|
|
||
| ### Combining Flags | ||
|
|
||
| ```bash | ||
| # Preview only (no commit, no API call) | ||
| commit . --dry-run | ||
|
|
||
| # Generate and auto-commit | ||
| commit . --auto | ||
|
|
||
| # Generate with interactive review (default behavior) | ||
| commit . | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify auto-commit behavior regarding interactive review.
The documentation states that --auto will "Skip the interactive review and manual confirmation step" (line 148), but the implementation in cmd/cli/createMsg.go still presents the interactive loop (accept/regenerate/edit/exit) and only auto-commits after the user accepts the message.
The actual behavior is:
- Generate commit message
- Present interactive review (user must accept, regenerate, edit, or exit)
- If user accepts, copy to clipboard AND auto-commit (if
--autowas passed)
This is safer than skipping review entirely, but the documentation should accurately reflect this flow.
Consider revising the documentation to clarify:
### Auto Commit Mode
Automatically commit with the generated message without manual confirmation:
```bash
commit . --autoThis will:
- Generate the commit message using your configured LLM
+- Present the interactive review for you to accept, regenerate, or edit - Automatically execute
git commitwith the generated message
-- Skip the interactive review and manual confirmation step
+- Skip the manualgit commitstep after acceptance
<details>
<summary>🤖 Prompt for AI Agents</summary>
In README.md around lines 137 to 166, the docs incorrectly state that --auto
skips the interactive review; update the text to reflect the actual flow:
generate the commit message, present the interactive review
(accept/regenerate/edit/exit), and if the user accepts, automatically run git commit (i.e., skip the manual git commit step only after acceptance). Replace
the line that says "Skip the interactive review and manual confirmation step"
with wording that clarifies the interactive review is still shown and that
--auto only bypasses the manual git commit after acceptance; keep the note
about --dry-run precedence and platform support as-is.
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
Description
Added a auto commit flag,
commit . --autothat automatically commits after the LLM generates the commit message, and a condition has been putautoCommit && !dryRunwhich prevents auto flag to be called when dry run flag is used.Type of Change
Related Issue
Fixes #88
Changes Made
commit . --autoflag for this featureTesting
Checklist
Screenshots (if applicable)
Additional Notes
Used commits in this PR to test the --auto flag as well.
For Hacktoberfest Participants
Thank you for your contribution! 🎉
Summary by CodeRabbit
New Features
Documentation