Feature/multiline edit
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:
- Smart Enter behavior for optional fields: Press Enter on empty line to skip optional fields (scope,
body, footer)
- Required field validation: Shows helpful error messages when trying to skip required fields (subject)
- Full multiline support: Use Enter for new lines and Alt+Enter to finish multiline input
- Clear user guidance: Context-aware help messages and error handling with Ctrl+C abort option
Before This PR:
- No multiline input support - all fields were single-line only
- Users were limited to basic commit messages
- No way to add detailed descriptions or multiline commit bodies
- No intelligent handling of optional vs required fields
After This PR:
- Full multiline support for all input fields
- Intuitive Enter-to-skip behavior for optional fields
- Proper validation and error handling for required fields
- Enhanced user experience with clear guidance
Checklist
- [x] I have read the contributing guidelines
Code Changes
- [x] Add test cases to all the changes
- [x] Run
poetry alllocally to ensure this change passes linter check and tests - [x] Manually test the changes:
- [x] Verify the feature works as expected in real-world scenarios
- [x] Test edge cases and error conditions
- [x] Ensure backward compatibility is maintained
- [x] Document manual testing steps performed
- [x] Update the documentation for the changes
Documentation Changes
- [x] Run
poetry doclocally to ensure the documentation pages render correctly - [x] Check and fix any broken links (internal or external) in the documentation
Expected Behavior
For Optional Fields (scope, body, footer):
- Pressing Enter on empty line skips the field
- Pressing Enter after typing content adds a new line for multiline input
- Alt+Enter finishes and submits the input
For Required Fields (subject):
- Pressing Enter on empty line shows error with guidance
- Pressing Enter after typing content adds a new line for multiline input
- Alt+Enter finishes and submits the input
- Ctrl+C aborts the commit session
Hi @anasalaqeel , Thanks for contribution. The pipeline failed because some of your commit messages doesn't follow conventional commit. Could you help to rebase your branch and amend the commit messages? Thanks.
But isn't #346 already fixed by #348?
@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
But isn't #346 already fixed by #348?
The proposed fix doesn't work, and it's not even documented anywhere. My solution is a complete game-changer
I didn't commit on your branch... The commit which confused you is from the master branch, and it appears on your branch because you merged / rebased the branch If you check the current master branch then you'll find the same commit
But isn't #346 already fixed by #348?
The proposed fix doesn't work, and it's not even documented anywhere.
My solution is a complete game-changer
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.
Codecov Report
:x: Patch coverage is 74.60317% with 16 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 97.74%. Comparing base (120d514) to head (8d0a92a).
:warning: Report is 881 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| commitizen/commands/commit.py | 73.33% | 16 Missing :warning: |
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
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 97.74% <74.60%> (+0.40%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
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)
conflict