@@ -425,7 +425,7 @@ test('Current tag is used', async () => {
425425} , 15000 ) ;
426426
427427test ( 'Bump each commit works' , async ( ) => {
428-
428+
429429 const repo = createTestRepo ( { tagPrefix : '' , bumpEachCommit : true } ) ; // 0.0.0
430430
431431 expect ( ( await repo . runAction ( ) ) . formattedVersion ) . toBe ( '0.0.0+0' ) ;
@@ -651,7 +651,7 @@ test('Correct previous version is returned when using branches', async () => {
651651 const result = await repo . runAction ( ) ;
652652
653653 expect ( result . previousVersion ) . toBe ( '2.0.1' ) ;
654- expect ( result . formattedVersion ) . toBe ( '2.0.2+0' ) ;
654+ expect ( result . formattedVersion ) . toBe ( '2.0.2+0' ) ;
655655} , 15000 ) ;
656656
657657test ( 'Correct previous version is returned when directly tagged' , async ( ) => {
@@ -707,4 +707,133 @@ test('Namespace can contains a slash', async () => {
707707
708708 expect ( result . formattedVersion ) . toBe ( '0.0.2+1' ) ;
709709 expect ( subprojectResult . formattedVersion ) . toBe ( '0.1.1+0' ) ;
710+ } , 15000 ) ;
711+
712+ test ( 'Namespace can contains a dot' , async ( ) => {
713+ const repo = createTestRepo ( { tagPrefix : '' } ) ;
714+
715+ repo . makeCommit ( 'Initial Commit' ) ;
716+ repo . exec ( 'git tag 0.0.1' ) ;
717+ repo . makeCommit ( 'Second Commit' ) ;
718+ repo . exec ( 'git tag 0.1.0-sub.project' ) ;
719+ repo . makeCommit ( 'Third Commit' ) ;
720+ repo . exec ( 'git tag 0.2.0-sub/project' ) ;
721+ repo . makeCommit ( 'fourth Commit' ) ;
722+
723+ const result = await repo . runAction ( ) ;
724+ const subprojectResult = await repo . runAction ( { namespace : "sub.project" } ) ;
725+
726+ expect ( result . formattedVersion ) . toBe ( '0.0.2+2' ) ;
727+ expect ( subprojectResult . formattedVersion ) . toBe ( '0.1.1+1' ) ;
728+ } , 15000 ) ;
729+
730+ test ( 'Patch increments only once' , async ( ) => {
731+ const repo = createTestRepo ( { tagPrefix : '' , versionFormat : "${major}.${minor}.${patch}" } ) ;
732+
733+ repo . makeCommit ( 'Initial Commit' ) ;
734+ repo . exec ( 'git tag 0.0.1' ) ;
735+ const firstResult = await repo . runAction ( ) ;
736+ repo . makeCommit ( 'Second Commit' ) ;
737+ const secondResult = await repo . runAction ( ) ;
738+ repo . makeCommit ( 'Third Commit' ) ;
739+ const thirdResult = await repo . runAction ( ) ;
740+ repo . makeCommit ( 'fourth Commit' ) ;
741+ const fourthResult = await repo . runAction ( ) ;
742+
743+
744+ expect ( firstResult . formattedVersion ) . toBe ( '0.0.1' ) ;
745+ expect ( secondResult . formattedVersion ) . toBe ( '0.0.2' ) ;
746+ expect ( thirdResult . formattedVersion ) . toBe ( '0.0.2' ) ;
747+ expect ( fourthResult . formattedVersion ) . toBe ( '0.0.2' ) ;
748+
749+ } , 15000 ) ;
750+
751+ test ( 'Patch increments each time when bump each commit is set' , async ( ) => {
752+ const repo = createTestRepo ( { tagPrefix : '' , versionFormat : "${major}.${minor}.${patch}" , bumpEachCommit : true } ) ;
753+
754+ repo . makeCommit ( 'Initial Commit' ) ;
755+ repo . exec ( 'git tag 0.0.1' ) ;
756+ const firstResult = await repo . runAction ( ) ;
757+ repo . makeCommit ( 'Second Commit' ) ;
758+ const secondResult = await repo . runAction ( ) ;
759+ repo . makeCommit ( 'Third Commit' ) ;
760+ const thirdResult = await repo . runAction ( ) ;
761+ repo . makeCommit ( 'fourth Commit' ) ;
762+ const fourthResult = await repo . runAction ( ) ;
763+
764+
765+ expect ( firstResult . formattedVersion ) . toBe ( '0.0.1' ) ;
766+ expect ( secondResult . formattedVersion ) . toBe ( '0.0.2' ) ;
767+ expect ( thirdResult . formattedVersion ) . toBe ( '0.0.3' ) ;
768+ expect ( fourthResult . formattedVersion ) . toBe ( '0.0.4' ) ;
769+
770+ } , 15000 ) ;
771+
772+ test ( 'Current commit is provided' , async ( ) => {
773+ const repo = createTestRepo ( { tagPrefix : '' , versionFormat : "${major}.${minor}.${patch}" } ) ;
774+
775+ repo . makeCommit ( 'Initial Commit' ) ;
776+ repo . makeCommit ( 'Second Commit' ) ;
777+ repo . makeCommit ( 'Third Commit' ) ;
778+ repo . makeCommit ( 'fourth Commit' ) ;
779+ repo . exec ( 'git tag 0.0.1' ) ;
780+ const result = await repo . runAction ( ) ;
781+
782+
783+ expect ( result . currentCommit ) . toBeTruthy ( ) ;
784+
785+ } , 15000 ) ;
786+
787+ test ( 'Prerelease tags are ignored on current commit' , async ( ) => {
788+ const repo = createTestRepo ( {
789+ minorPattern : '/.*/'
790+ } ) ;
791+
792+ let i = 0 ;
793+
794+ const validate = async ( version : string , changed : boolean = true ) => {
795+ const result = await repo . runAction ( ) ;
796+ expect ( result . formattedVersion ) . toBe ( version ) ;
797+ expect ( result . changed ) . toBe ( changed ) ;
798+ }
799+
800+ await validate ( '0.0.0+0' , false ) ;
801+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
802+ await validate ( '0.1.0+0' ) ;
803+ repo . exec ( 'git tag v0.0.0' ) ;
804+ await validate ( '0.0.0+0' , false ) ;
805+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
806+ await validate ( '0.1.0+0' ) ;
807+ repo . exec ( 'git tag v1.0.0-rc1' ) ;
808+ await validate ( '0.1.0+0' ) ;
809+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
810+ await validate ( '0.1.0+1' ) ;
811+ repo . exec ( 'git tag v1.0.0-rc2' ) ;
812+ await validate ( '0.1.0+1' ) ;
813+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
814+ await validate ( '0.1.0+2' ) ;
815+ repo . exec ( 'git tag v1.0.0-rc3' ) ;
816+ await validate ( '0.1.0+2' ) ;
817+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
818+ await validate ( '0.1.0+3' ) ;
819+ repo . exec ( 'git tag v1.0.0' ) ;
820+ await validate ( '1.0.0+0' , false ) ;
821+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
822+ await validate ( '1.1.0+0' ) ;
823+ repo . exec ( 'git tag v1.1.0-rc2' ) ;
824+ await validate ( '1.1.0+0' ) ;
825+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
826+ await validate ( '1.1.0+1' ) ;
827+ repo . exec ( 'git tag v1.1.0-rc4' ) ;
828+ await validate ( '1.1.0+1' ) ;
829+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
830+ await validate ( '1.1.0+2' ) ;
831+ repo . exec ( 'git tag v1.1.0-rc8' ) ;
832+ await validate ( '1.1.0+2' ) ;
833+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
834+ await validate ( '1.1.0+3' ) ;
835+ repo . exec ( 'git tag v1.1.0-rc9' ) ;
836+ await validate ( '1.1.0+3' ) ;
837+ repo . makeCommit ( `Commit ${ i ++ } ` ) ;
838+ await validate ( '1.1.0+4' ) ;
710839} , 15000 ) ;
0 commit comments