Skip to content

fix: add support for commit message file argument for pre-commit#368

Closed
Copilot wants to merge 1 commit intofix/add-commit-msg-filefrom
copilot/sub-pr-366
Closed

fix: add support for commit message file argument for pre-commit#368
Copilot wants to merge 1 commit intofix/add-commit-msg-filefrom
copilot/sub-pr-366

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Addresses feedback from PR #366 review: adds comprehensive test coverage for positional argument handling and ensures message validation is always enabled when a file path is provided.

Changes

  • Test Coverage: Added TestPositionalArgumentFeature class with 5 tests covering:

    • Positional argument without --message flag
    • Positional argument with --message flag
    • Positional argument with other check flags (--branch)
    • Invalid commit message validation via positional argument
    • Non-existent file fallback behavior
  • Logic Simplification: Refactored positional argument handling in main.py (lines 319-325) to unconditionally enable message checking when commit_msg_file is provided, eliminating conditional logic that could cause files to be silently ignored.

  • Imperative Verb: Added "refactor" to IMPERATIVES set for conventional commit validation.

Test Results

$ pytest tests/main_test.py::TestPositionalArgumentFeature -v
collected 5 items

test_positional_arg_without_message_flag PASSED
test_positional_arg_with_message_flag PASSED  
test_positional_arg_with_branch_flag PASSED
test_positional_arg_invalid_commit PASSED
test_positional_arg_nonexistent_file PASSED

All new tests pass. One pre-existing test failure in test_main_with_message_empty_string_no_stdin_with_git is unrelated to these changes (mock configuration issue).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

@github-actions github-actions bot added the bug Something isn't working label Feb 3, 2026
Copilot AI changed the title [WIP] Fix: Add support for commit message file argument for pre-commit fix: add support for commit message file argument for pre-commit Feb 3, 2026
Copilot AI requested a review from shenxianpeng February 3, 2026 07:47
@shenxianpeng shenxianpeng marked this pull request as ready for review February 3, 2026 07:49
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

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

@shenxianpeng shenxianpeng deleted the copilot/sub-pr-366 branch February 3, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants