@@ -461,6 +461,40 @@ def test_changelog_config_flag_increment(
461
461
file_regression .check (out , extension = ".md" )
462
462
463
463
464
+ @pytest .mark .parametrize ("test_input" , ["rc" , "alpha" , "beta" ])
465
+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
466
+ def test_changelog_config_flag_merge_prerelease (
467
+ mocker : MockFixture , changelog_path , config_path , file_regression , test_input
468
+ ):
469
+ with open (config_path , "a" ) as f :
470
+ f .write ("merge_prerelease = true\n " )
471
+
472
+ create_file_and_commit ("irrelevant commit" )
473
+ mocker .patch ("commitizen.git.GitTag.date" , "1970-01-01" )
474
+ git .tag ("1.0.0" )
475
+
476
+ create_file_and_commit ("feat: add new output" )
477
+ create_file_and_commit ("fix: output glitch" )
478
+
479
+ testargs = ["cz" , "bump" , "--prerelease" , test_input , "--yes" ]
480
+ mocker .patch .object (sys , "argv" , testargs )
481
+ cli .main ()
482
+
483
+ create_file_and_commit ("fix: mama gotta work" )
484
+ create_file_and_commit ("feat: add more stuff" )
485
+ create_file_and_commit ("Merge into master" )
486
+
487
+ testargs = ["cz" , "changelog" ]
488
+
489
+ mocker .patch .object (sys , "argv" , testargs )
490
+ cli .main ()
491
+
492
+ with open (changelog_path , "r" ) as f :
493
+ out = f .read ()
494
+
495
+ file_regression .check (out , extension = ".md" )
496
+
497
+
464
498
@pytest .mark .usefixtures ("tmp_commitizen_project" )
465
499
def test_changelog_config_start_rev_option (
466
500
mocker : MockFixture , capsys , config_path , file_regression
@@ -549,6 +583,40 @@ def test_changelog_incremental_with_release_candidate_version(
549
583
file_regression .check (out , extension = ".md" )
550
584
551
585
586
+ @pytest .mark .parametrize ("test_input" , ["rc" , "alpha" , "beta" ])
587
+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
588
+ def test_changelog_release_candidate_version_with_merge_prerelease (
589
+ mocker : MockFixture , changelog_path , file_regression , test_input
590
+ ):
591
+ """Fix #357"""
592
+ with open (changelog_path , "w" ) as f :
593
+ f .write (KEEP_A_CHANGELOG )
594
+ create_file_and_commit ("irrelevant commit" )
595
+ mocker .patch ("commitizen.git.GitTag.date" , "1970-01-01" )
596
+ git .tag ("1.0.0" )
597
+
598
+ create_file_and_commit ("feat: add new output" )
599
+ create_file_and_commit ("fix: output glitch" )
600
+
601
+ testargs = ["cz" , "bump" , "--prerelease" , test_input , "--yes" ]
602
+ mocker .patch .object (sys , "argv" , testargs )
603
+ cli .main ()
604
+
605
+ create_file_and_commit ("fix: mama gotta work" )
606
+ create_file_and_commit ("feat: add more stuff" )
607
+ create_file_and_commit ("Merge into master" )
608
+
609
+ testargs = ["cz" , "changelog" , "--merge-prerelease" ]
610
+
611
+ mocker .patch .object (sys , "argv" , testargs )
612
+ cli .main ()
613
+
614
+ with open (changelog_path , "r" ) as f :
615
+ out = f .read ()
616
+
617
+ file_regression .check (out , extension = ".md" )
618
+
619
+
552
620
@pytest .mark .usefixtures ("tmp_commitizen_project" )
553
621
def test_changelog_with_filename_as_empty_string (
554
622
mocker : MockFixture , changelog_path , config_path
0 commit comments