feat: enhance workflow with pre-commit hooks#9
Merged
Conversation
This commit introduces several significant enhancements to the `git-commit-helper-it` tool, focusing on improving the AI-driven workflow, adding flexibility, and enhancing the overall user experience.
Key changes include:
* **AI-Powered Commit Body Generation**: The tool can now generate a detailed commit body in addition to the subject, providing a more comprehensive commit message based on the staged changes. This addresses the "why" behind the changes, not just the "what".
* **AI-Powered Branch Naming Suggestions**: When a user is on a protected branch (e.g., `main`, `master`), the tool will now suggest a descriptive branch name using AI, promoting consistent branch naming conventions and streamlining the process of creating new feature branches.
* **Non-Interactive Mode (`-y` / `--yes`)**: A new `-y` or `--yes` flag has been added, allowing users to automatically accept all AI suggestions and prompts. This is particularly useful for scripting, CI/CD pipelines, or users who prefer a quicker, automated workflow.
* **Configurable Pre-Commit Hooks**: Users can now define custom shell commands (e.g., `npm run lint`, `npm test`) in the `gch.config.json` file. These commands will run automatically before the AI code review, ensuring code quality and test coverage before a commit is finalized. If any command fails, the commit process is aborted.
* **Improved Branch Protection Flow**:
* The `checkBranchAndMaybeCreateNew` function now accepts the `autoConfirm` flag, allowing automated branch creation in non-interactive mode.
* If no changes are detected, a more informative message is displayed when the AI cannot suggest a branch name.
* **Flexible Configuration**:
* The `init-config.cjs` template has been updated to include new default settings for `aiReviewEnabled` (true by default) and `preCommitCommands`.
* The `geminiModel` default has been updated from `gemini-2.5-flash` to `gemini-1.5-flash` for potentially better performance/cost balance.
* **Enhanced Commit Message Handling**:
* The `git.js` `commit` function now uses a temporary file to pass the commit message to Git, which correctly handles complex messages (including multi-line bodies) and special characters, preventing command line parsing issues.
* The `getDiff` function now accepts a `cached` parameter, allowing the retrieval of either staged or unstaged diffs as needed for different AI features (e.g., staged for commit message, unstaged for branch name suggestion).
* **Documentation Updates**: The `README.md` (English and Italian) has been thoroughly updated to reflect all new features, configurations, and usage instructions, including the new command-line options and workflow steps. This ensures users are fully aware of the tool's capabilities.
* **Localization**: New strings have been added to `en.json` and `it.json` to support the new features, such as messages for running pre-commit hooks, branch name suggestions, and commit body generation.
These changes collectively make the `git-commit-helper-it` tool more powerful, versatile, and user-friendly, catering to a wider range of developer workflows and automation needs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit introduces several significant enhancements to the
git-commit-helper-ittool, focusing on improving the AI-driven workflow, adding flexibility, and enhancing the overall user experience.Key changes include:
main,master), the tool will now suggest a descriptive branch name using AI, promoting consistent branch naming conventions and streamlining the process of creating new feature branches.-y/--yes): A new-yor--yesflag has been added, allowing users to automatically accept all AI suggestions and prompts. This is particularly useful for scripting, CI/CD pipelines, or users who prefer a quicker, automated workflow.npm run lint,npm test) in thegch.config.jsonfile. These commands will run automatically before the AI code review, ensuring code quality and test coverage before a commit is finalized. If any command fails, the commit process is aborted.checkBranchAndMaybeCreateNewfunction now accepts theautoConfirmflag, allowing automated branch creation in non-interactive mode.init-config.cjstemplate has been updated to include new default settings foraiReviewEnabled(true by default) andpreCommitCommands.geminiModeldefault has been updated fromgemini-2.5-flashtogemini-1.5-flashfor potentially better performance/cost balance.git.jscommitfunction now uses a temporary file to pass the commit message to Git, which correctly handles complex messages (including multi-line bodies) and special characters, preventing command line parsing issues.getDifffunction now accepts acachedparameter, allowing the retrieval of either staged or unstaged diffs as needed for different AI features (e.g., staged for commit message, unstaged for branch name suggestion).README.md(English and Italian) has been thoroughly updated to reflect all new features, configurations, and usage instructions, including the new command-line options and workflow steps. This ensures users are fully aware of the tool's capabilities.en.jsonandit.jsonto support the new features, such as messages for running pre-commit hooks, branch name suggestions, and commit body generation.These changes collectively make the
git-commit-helper-ittool more powerful, versatile, and user-friendly, catering to a wider range of developer workflows and automation needs.