@@ -322,3 +322,31 @@ test.serial('should not roll back with risky config', async t => {
322
322
await gitClient . beforeRelease ( ) ;
323
323
t . is ( 'rollbackOnce' in gitClient , false ) ;
324
324
} ) ;
325
+
326
+ test . serial ( 'should return latest tag from default branch (not parent commit)' , async t => {
327
+ const gitClient = factory ( Git , {
328
+ options : { git : { getLatestTagFromAllRefs : true } }
329
+ } ) ;
330
+ sh . exec ( 'git init' ) ;
331
+ gitAdd ( 'main' , 'file' , 'Add file in main' ) ;
332
+ const defaultBranchName = await gitClient . getBranchName ( ) ;
333
+ const developBranchName = 'develop' ;
334
+ const featureBranchPrefix = 'feature' ;
335
+ await gitClient . tag ( { name : '1.0.0' } ) ;
336
+ sh . exec ( `git branch ${ developBranchName } ${ defaultBranchName } ` ) ;
337
+ sh . exec ( `git checkout -b ${ featureBranchPrefix } /first ${ developBranchName } ` ) ;
338
+ gitAdd ( 'feature/1' , 'file' , 'Update file in feature branch (1)' ) ;
339
+ sh . exec ( `git checkout ${ developBranchName } ` ) ;
340
+ sh . exec ( `git merge --no-ff ${ featureBranchPrefix } /first` ) ;
341
+ await gitClient . tag ( { name : '1.1.0-rc.1' } ) ;
342
+ sh . exec ( `git checkout ${ defaultBranchName } ` ) ;
343
+ sh . exec ( `git merge --no-ff ${ developBranchName } ` ) ;
344
+ await gitClient . tag ( { name : '1.1.0' } ) ;
345
+ sh . exec ( `git checkout -b ${ featureBranchPrefix } /second ${ developBranchName } ` ) ;
346
+ gitAdd ( 'feature/2' , 'file' , 'Update file again, in feature branch (2)' ) ;
347
+ sh . exec ( `git checkout ${ developBranchName } ` ) ;
348
+ sh . exec ( `git merge --no-ff ${ featureBranchPrefix } /second` ) ;
349
+ {
350
+ t . is ( await gitClient . getLatestTagName ( ) , '1.1.0' ) ;
351
+ }
352
+ } ) ;
0 commit comments