Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
anasalaqeel wants to merge10 commits intocommitizen-tools:master
base:master
Choose a base branch
Loading
fromanasalaqeel:feature/multiline-edit

Conversation

@anasalaqeel
Copy link

@anasalaqeelanasalaqeel commentedSep 24, 2025
edited
Loading

Description

This PR implementsmultiline 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

Code Changes

  • Add test cases to all the changes
  • Runpoetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Runpoetry doc locally to ensure the documentation pages render correctly
  • 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

@bearomorphism
Copy link
Collaborator

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.

@bearomorphism
Copy link
Collaborator

bearomorphism commentedSep 25, 2025
edited
Loading

But isn't#346 already fixed by#348?

@anasalaqeel
Copy link
Author

@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

@anasalaqeel
Copy link
Author

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

@bearomorphism
Copy link
Collaborator

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

@bearomorphism
Copy link
Collaborator

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.

- 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
…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
Copy link

codecovbot commentedSep 28, 2025
edited
Loading

Codecov Report

❌ Patch coverage is74.60317% with16 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.74%. Comparing base (120d514) to head (8d0a92a).
⚠️ Report is 881 commits behind head on master.

Files with missing linesPatch %Lines
commitizen/commands/commit.py73.33%16 Missing⚠️
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
FlagCoverage Δ
unittests97.74% <74.60%> (+0.40%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- 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 organizationAddresses feedback from@bearomorphism in PRcommitizen-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 featureRefactored 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
@bearomorphism
Copy link
Collaborator

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)

anasalaqeel reacted with thumbs up emoji

…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
@bearomorphism
Copy link
Collaborator

conflict

Lee-W reacted with thumbs up emoji

@Lee-WLee-W marked this pull request as draftDecember 12, 2025 03:10
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@woilewoileAwaiting requested review from woilewoile is a code owner

@Lee-WLee-WAwaiting requested review from Lee-WLee-W is a code owner

@noirbizarrenoirbizarreAwaiting requested review from noirbizarrenoirbizarre is a code owner

@bearomorphismbearomorphismAwaiting requested review from bearomorphism

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

Projects

None yet

Milestone

4.11.0

Development

Successfully merging this pull request may close these issues.

Breaking change should support multiline

3 participants

@anasalaqeel@bearomorphism@Lee-W

[8]ページ先頭

©2009-2025 Movatter.jp