Skip to content

Comments

test: robustify conventional merge commit#10

Merged
michen00 merged 29 commits intomainfrom
test/robustify-conventional-merge-commit
Jan 10, 2026
Merged

test: robustify conventional merge commit#10
michen00 merged 29 commits intomainfrom
test/robustify-conventional-merge-commit

Conversation

@michen00
Copy link
Owner

@michen00 michen00 commented Jan 10, 2026

  • refactored the tests
  • centered the trigger on ^\s*([Mm]erge[ds]?|[Ss]quash(e[ds])?)[(!:\[]?( .*)?$, ^\s*([Mm]erge[ds]?|[Ss]quash(e[ds])?)\b.*$ roughly
  • added example tests

Note

Improves commit message automation and test coverage.

  • Expands scripts/conventional-merge-commit to handle leading whitespace and a broader set of merge/squash variants via case patterns; rewrites to chore: ... while preserving bodies
  • Adds parallelized CSV-driven tests (720288 cases) plus shared helpers; refactors enhance-scope tests and adds basic usage examples; updates test runner
  • Updates .pre-commit-config.yaml to exclude the large CSV from the trailing-whitespace hook

Written by Cursor Bugbot for commit 663b713. Configure here.

- Rename SCRIPT_DIR to TEST_SCRIPT_DIR for clarity
- Remove redundant comments from colors.sh
Move test_enhance_scope function to reusable helper file.
Helper defines its own HOOK path via BASH_SOURCE.
Add test-examples.sh demonstrating basic hook usage.
Tests body preservation for both hooks.
- Support lowercase 'merge ...' messages
- Support bare 'Merge' and 'merge' keywords
- Add comprehensive edge case tests
Handle Merge, Merged, Merges, Squash, Squashed, Squashes
(case-insensitive first letter) with optional leading whitespace
and separator chars (space, (, !, :, [).

Trigger pattern: ^\s*([Mm]erge[ds]?|[Ss]quash(e[ds])?)[(!:\[]?( .*)?$
Create conventional-merge-commit-helper.sh with unified
test_conventional_merge_commit() function supporting both
first-line-only and body-preservation tests.

Update test-examples.sh to use shared helper.
Add exhaustive test cases for Merge/Squash variants covering
keywords, separators, arguments, and leading whitespace.

Parallelize CSV tests using background jobs (8 concurrent)
with early termination on first failure.

Exclude CSV from trailing-whitespace hook (test data includes
intentional trailing spaces).
Copilot AI review requested due to automatic review settings January 10, 2026 02:19
@github-actions
Copy link

🎉 Welcome to the custom-commit-hooks community! 🎉

Thank you for your contribution! We appreciate your time and effort in submitting this pull request. A maintainer will review it soon. If you have any questions, feel free to ask!

Thank you for your cooperation 🙏

@gemini-code-assist
Copy link
Contributor

gemini-code-assist bot commented Jan 10, 2026

Summary of Changes

Hello @michen00, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the reliability and testability of the commit message hooks. It significantly upgrades the conventional-merge-commit hook to more accurately identify and transform merge and squash messages, while also overhauling the testing infrastructure. The changes introduce a robust, data-driven testing approach, ensuring that commit message transformations are consistently applied across a wide array of scenarios.

Highlights

  • Robust Conventional Commit Detection: The conventional-merge-commit hook now uses a more sophisticated pattern to identify merge and squash messages, handling various tenses (Merge, Merged, Merges, Squash, Squashed, Squashes) and delimiters (space, parentheses, exclamation, colon, brackets), as well as leading whitespace.
  • Comprehensive Test Refactoring: The testing suite for commit hooks has been significantly refactored, introducing dedicated helper scripts (conventional-merge-commit-helper.sh, enhance-scope-helper.sh) to standardize test execution.
  • Data-Driven Testing: A new CSV file (test-conventional-merge-commit.csv) with 720288 test cases has been added, enabling parallelized and extensive validation of the conventional-merge-commit hook's behavior.
  • Example Test Cases: New example tests (test-examples.sh) have been introduced to cover specific scenarios, including the preservation of commit message bodies during transformations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the robustness of the conventional-merge-commit hook and its tests. The test suite is now much more comprehensive with CSV-driven parallel tests, and the test scripts have been nicely refactored into shared helpers. However, I've found a critical issue in the core logic of the conventional-merge-commit script that will cause some of the new tests to fail. I've also noticed a minor issue in one of the new example tests. My feedback focuses on these two points.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR robustifies the conventional-merge-commit hook by expanding its trigger pattern and comprehensively testing edge cases. The hook now handles various forms of merge and squash commit messages (e.g., "Merged", "Merges", "Squashed", "Squashes") with different punctuation patterns, and includes extensive test coverage.

Key changes:

  • Expanded trigger pattern to match merge/squash variants: Merge[d|s], Squash[ed|es] with case-insensitivity and leading whitespace handling
  • Added 720288 CSV-driven test cases executed in parallel for comprehensive coverage
  • Refactored test infrastructure with reusable helper functions for both hooks

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/conventional-merge-commit Enhanced trigger pattern to handle merge/squash variants with punctuation (!, :, [, () and leading whitespace
tests/test-conventional-merge-commit.sh Refactored to use CSV-driven tests (720 cases) with parallel execution and manual edge case tests
tests/test-conventional-merge-commit.csv New CSV file with 720 test cases covering all merge/squash keyword variants with different punctuation and whitespace
tests/conventional-merge-commit-helper.sh New shared helper function for testing conventional-merge-commit hook with body preservation checks
tests/enhance-scope-helper.sh New shared helper function for testing enhance-scope hook, extracted from test script
tests/test-examples.sh New basic usage test file demonstrating both hooks with body preservation
tests/test-enhance-scope.sh Refactored to use shared helper function, removed duplicate body preservation test
tests/test-lib-commit-msg.sh Standardized variable naming (TEST_SCRIPT_DIR) and simplified path resolution
tests/test-runner.sh Added test-examples.sh to test suite and standardized variable naming
tests/colors.sh Removed redundant comments at file header
.pre-commit-config.yaml Excluded CSV test file from trailing-whitespace check to preserve intentional whitespace in test data

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 663b7134a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on February 5

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Allow commit_source=squash (from git merge --squash) to reach
the transformation logic, not just commit_source=merge.

Add test for squash commit source transformation.
Add optional expected_body parameter to test_enhance_scope helper
(matching test_conventional_merge_commit pattern).

The test named "Commit body preserved" now actually verifies
body content is preserved, not just the first line.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Modified test helpers to clarify expected_body parameter usage and
ensure full body content is captured from line 3 onward. Updated example
test cases to reflect these changes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

michen00 and others added 5 commits January 10, 2026 04:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Michael I Chen <michael.chen@aicadium.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Michael I Chen <michael.chen@aicadium.ai>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

michen00 and others added 3 commits January 10, 2026 05:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Michael I Chen <michael.chen@aicadium.ai>
Introduced a dedicated function to handle killing background jobs,
improving the cleanup process in the test script.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Michael I Chen <michael.chen@aicadium.ai>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

@michen00 michen00 merged commit 4463dd7 into main Jan 10, 2026
8 of 9 checks passed
@michen00 michen00 deleted the test/robustify-conventional-merge-commit branch January 10, 2026 05:36
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.

1 participant