-
-
Notifications
You must be signed in to change notification settings - Fork 302
Feature/multiline edit #1630
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
base: master
Are you sure you want to change the base?
Feature/multiline edit #1630
Conversation
Hi @anasalaqeel , |
0f11842
to
f9c3a69
Compare
@bearomorphism I've rebased and updated the commit messages to follow Conventional Commit format, but it seems you committed on this branch as well so It keeps failing. I think you are committed to the wrong branch |
I didn't commit on your branch... |
Got it. Just note that since you're removing an existing cli argument, this PR will be a breaking change. It would be better to deprecate the old argument first, and then completely remove it in the next major release. |
- Add ability to the answer inputs to aacept multilines. - No more accidental Enter key, now Enter key only breaks the line into a new line and it can be removed/undo using backspace key normally. - Now the user can submit the commit only when he is sure by pressing combination of Alt + Enter. BREAKING CHANGE:
Fix required and optional inputs skipping behaveioiur: For optional fields (scope, body, footer): - Press Enter on empty line skips the field - Press Enter after typing text adds new line for multiline input - Alt+Enter finishes multiline input For required fields (subject): - Press Enter on empty line shows red error message " This field is required. Please enter some content." and prevents newline - Press Enter after typing text adds new line for multiline input - Alt+Enter finishes input
6a542fa
to
2cc9ad8
Compare
…feature - Replace assert_called_once() with assert called for prompt mocks - Tests now work with new multiline behavior that calls questionary.prompt multiple times
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1630 +/- ##
==========================================
+ Coverage 97.33% 97.74% +0.40%
==========================================
Files 42 58 +16
Lines 2104 2744 +640
==========================================
+ Hits 2048 2682 +634
- Misses 56 62 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Use internal out module for colored prompts instead of ANSI codes - Extract all duplicated questionary prompt handling into helper functions - Remove outdated backslash continuation reference from commit message - Add comprehensive tests for edge cases and error scenarios - Fix type annotations and import organization Addresses feedback from @bearomorphism in PR commitizen-tools#1630: - Lines 95-102: Replace ANSI colors with out.info/out.error - Lines 88-97, 200-209: Extract duplicated try/catch blocks - Clean up breaking change references
Consolidate multiline input logic into dedicated _handle_multiline_question function, removing duplicated code from the main prompt loop. Improve type hints by using Style instead of Any, and refactor error message formatting for consistency.
…mit feature Refactored test files to improve maintainability and clarity: **test_commit_command.py:** - Created reusable mock_prompt fixture to eliminate duplicated mocking code - Updated all tests to use the new fixture pattern with _handle_questionary_prompt - Improved test for message length limit to properly test both success and failure cases - Simplified test logic by removing unnecessary variable assignments **test_commit_multiline.py:** - Restructured tests into focused test classes by functionality - Simplified test logic to directly test _handle_multiline_question function - Added parameterized tests for optional field detection - Improved test coverage for filter errors with proper retry behavior - Removed redundant implementation-level tests in favor of behavior tests - Enhanced test documentation and clarity
Thanks, now it is more readable and easier to be reviewed. Let's wait for the maintainer's input. (They have quite limited bandwidth recently) |
…est cases to cover previously untested code paths in the commit command: - Test ValueError with CzException context in _handle_questionary_prompt - Test manual_edit when editor executable is not found - Test multiline question handling when result is None with/without default values
Description
This PR implements multiline input functionality for the commit command - a completely new feature
that enables users to create detailed, well-formatted commit messages with multiline support.
Fixes #346
New Multiline Feature:
body, footer)
(subject)
Before This PR:
After This PR:
Checklist
guidelines
Code Changes
poetry all
locally to ensure this change passes linter check and testsDocumentation Changes
poetry doc
locally to ensure the documentation pages render correctlyExpected Behavior
For Optional Fields (scope, body, footer):
For Required Fields (subject):