@@ -408,6 +408,50 @@ describe('ref', () => {
408408 const ref = await Git . ref ( ) ;
409409 expect ( ref ) . toEqual ( 'refs/remotes/unusual-format' ) ;
410410 } ) ;
411+
412+ it ( 'returns mocked detached tag ref when commit also has branch decorations' , async ( ) => {
413+ vi . spyOn ( Exec , 'getExecOutput' ) . mockImplementation ( ( cmd , args ) : Promise < ExecOutput > => {
414+ const fullCmd = `${ cmd } ${ args ?. join ( ' ' ) } ` ;
415+ let result = '' ;
416+ switch ( fullCmd ) {
417+ case 'git branch --show-current' :
418+ result = '' ;
419+ break ;
420+ case 'git show -s --pretty=%D' :
421+ result = 'HEAD, tag: v8.0.0, origin/release-branch' ;
422+ break ;
423+ }
424+ return Promise . resolve ( {
425+ stdout : result ,
426+ stderr : '' ,
427+ exitCode : 0
428+ } ) ;
429+ } ) ;
430+ const ref = await Git . ref ( ) ;
431+ expect ( ref ) . toEqual ( 'refs/tags/v8.0.0' ) ;
432+ } ) ;
433+
434+ it ( 'returns mocked detached tag ref (shallow clone) when commit also has branch decorations' , async ( ) => {
435+ vi . spyOn ( Exec , 'getExecOutput' ) . mockImplementation ( ( cmd , args ) : Promise < ExecOutput > => {
436+ const fullCmd = `${ cmd } ${ args ?. join ( ' ' ) } ` ;
437+ let result = '' ;
438+ switch ( fullCmd ) {
439+ case 'git branch --show-current' :
440+ result = '' ;
441+ break ;
442+ case 'git show -s --pretty=%D' :
443+ result = 'grafted, HEAD, tag: v8.0.0, origin/release-branch' ;
444+ break ;
445+ }
446+ return Promise . resolve ( {
447+ stdout : result ,
448+ stderr : '' ,
449+ exitCode : 0
450+ } ) ;
451+ } ) ;
452+ const ref = await Git . ref ( ) ;
453+ expect ( ref ) . toEqual ( 'refs/tags/v8.0.0' ) ;
454+ } ) ;
411455} ) ;
412456
413457describe ( 'fullCommit' , ( ) => {
0 commit comments