Skip to content

feat: enhance workflow with pre-commit hooks#9

Merged
moris88 merged 1 commit into
mainfrom
feat/enhance-cli-workflow
Aug 4, 2025
Merged

feat: enhance workflow with pre-commit hooks#9
moris88 merged 1 commit into
mainfrom
feat/enhance-cli-workflow

Conversation

@moris88

@moris88 moris88 commented Aug 4, 2025

Copy link
Copy Markdown
Owner

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 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.
@moris88 moris88 self-assigned this Aug 4, 2025
@moris88 moris88 added the enhancement New feature or request label Aug 4, 2025
@moris88 moris88 merged commit 31d0f7a into main Aug 4, 2025
@moris88 moris88 deleted the feat/enhance-cli-workflow branch August 4, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant