File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class CommitArgs(TypedDict, total=False):
3838 edit : bool
3939 extra_cli_args : list [str ]
4040 message_length_limit : int
41- body_length_limit : int
41+ body_length_limit : int | None
4242 no_retry : bool
4343 signoff : bool
4444 write_message_to_file : Path | None
@@ -109,9 +109,9 @@ def _wrap_body(self, message: str) -> str:
109109 Wrap the body of the commit message to the --body-length-limit length.
110110 """
111111
112- body_length_limit = self .arguments .get (
113- " body_length_limit" , self . config . settings [ "body_length_limit" ]
114- )
112+ body_length_limit = self .arguments .get ("body_length_limit" )
113+ if body_length_limit is None :
114+ body_length_limit = self . config . settings [ "body_length_limit" ]
115115 # By the contract, body_length_limit is set to 0 for no limit
116116 if not body_length_limit or body_length_limit <= 0 :
117117 return message
Original file line number Diff line number Diff line change @@ -448,6 +448,35 @@ def test_commit_command_body_length_limit(
448448 )
449449
450450
451+ @pytest .mark .usefixtures ("staging_is_clean" )
452+ def test_commit_command_uses_configured_body_length_limit_when_cli_option_is_omitted (
453+ config ,
454+ commit_mock ,
455+ mocker : MockFixture ,
456+ ):
457+ config .settings ["body_length_limit" ] = 20
458+ mocker .patch (
459+ "questionary.prompt" ,
460+ return_value = {
461+ "prefix" : "feat" ,
462+ "subject" : "add feature" ,
463+ "scope" : "" ,
464+ "is_breaking_change" : False ,
465+ "body" : "This body line should wrap at the configured limit" ,
466+ "footer" : "" ,
467+ },
468+ )
469+
470+ commands .Commit (config , {"body_length_limit" : None })()
471+
472+ committed_message = commit_mock .call_args [0 ][0 ]
473+ assert committed_message .split ("\n " )[2 :] == [
474+ "This body line" ,
475+ "should wrap at the" ,
476+ "configured limit" ,
477+ ]
478+
479+
451480@pytest .mark .usefixtures ("staging_is_clean" )
452481def test_commit_command_body_length_limit_preserves_whitespace_only_lines (
453482 config ,
You can’t perform that action at this time.
0 commit comments