File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def commit(
112112 f .write (message .encode ("utf-8" ))
113113 f .close ()
114114
115- command = f" git commit { args } -F { f .name } "
115+ command = f' git commit { args } -F " { f .name } "'
116116
117117 if committer_date and os .name == "nt" : # pragma: no cover
118118 # Using `cmd /v /c "{command}"` sets environment variables only for that command
Original file line number Diff line number Diff line change @@ -293,3 +293,32 @@ def test_create_tag_with_message(tmp_commitizen_project):
293293 assert git .get_tag_message (tag_name ) == (
294294 tag_message if platform .system () != "Windows" else f"'{ tag_message } '"
295295 )
296+
297+
298+ @pytest .mark .parametrize (
299+ "file_path,expected_cmd" ,
300+ [
301+ (
302+ "/tmp/temp file" ,
303+ 'git commit --signoff -F "/tmp/temp file"' ,
304+ ), # File contains spaces
305+ (
306+ "/tmp dir/temp file" ,
307+ 'git commit --signoff -F "/tmp dir/temp file"' ,
308+ ), # Path contains spaces
309+ (
310+ "/tmp/tempfile" ,
311+ 'git commit --signoff -F "/tmp/tempfile"' ,
312+ ), # Path does not contain spaces
313+ ],
314+ )
315+ def test_commit_with_spaces_in_path (mocker , file_path , expected_cmd ):
316+ mock_run = mocker .patch ("commitizen.cmd.run" , return_value = FakeCommand ())
317+ mock_unlink = mocker .patch ("os.unlink" )
318+ mock_temp_file = mocker .patch ("commitizen.git.NamedTemporaryFile" )
319+ mock_temp_file .return_value .name = file_path
320+
321+ git .commit ("feat: new feature" , "--signoff" )
322+
323+ mock_run .assert_called_once_with (expected_cmd )
324+ mock_unlink .assert_called_once_with (file_path )
You can’t perform that action at this time.
0 commit comments