@@ -436,6 +436,16 @@ describe('GitService', () => {
436436 const result = await service . getLog ( 1 , database , 10 )
437437
438438 expect ( getRepoByIdMock ) . toHaveBeenCalledWith ( database , 1 )
439+ expect ( executeCommandMock ) . toHaveBeenNthCalledWith ( 1 , [
440+ 'git' ,
441+ '-C' ,
442+ '/path/to/repo' ,
443+ 'log' ,
444+ 'HEAD' ,
445+ '-n' ,
446+ '10' ,
447+ '--format=%H|%an|%ae|%at|%s'
448+ ] , { env : { } } )
439449 expect ( result ) . toHaveLength ( 2 )
440450 expect ( result [ 0 ] ) . toEqual ( {
441451 hash : 'abc123' ,
@@ -467,6 +477,50 @@ describe('GitService', () => {
467477
468478 expect ( result ) . toEqual ( [ ] )
469479 } )
480+
481+ it ( 'uses the requested branch when provided' , async ( ) => {
482+ const mockRepo = {
483+ id : 1 ,
484+ fullPath : '/path/to/repo' ,
485+ }
486+ getRepoByIdMock . mockReturnValue ( mockRepo as any )
487+ executeCommandMock . mockResolvedValueOnce ( '' ) . mockResolvedValueOnce ( '' )
488+
489+ await service . getLog ( 1 , database , 10 , 'feature/test' )
490+
491+ expect ( executeCommandMock ) . toHaveBeenNthCalledWith ( 1 , [
492+ 'git' ,
493+ '-C' ,
494+ '/path/to/repo' ,
495+ 'log' ,
496+ 'feature/test' ,
497+ '-n' ,
498+ '10' ,
499+ '--format=%H|%an|%ae|%at|%s'
500+ ] , { env : { } } )
501+ } )
502+
503+ it ( 'falls back to HEAD for blank branch values' , async ( ) => {
504+ const mockRepo = {
505+ id : 1 ,
506+ fullPath : '/path/to/repo' ,
507+ }
508+ getRepoByIdMock . mockReturnValue ( mockRepo as any )
509+ executeCommandMock . mockResolvedValueOnce ( '' ) . mockResolvedValueOnce ( '' )
510+
511+ await service . getLog ( 1 , database , 10 , ' ' )
512+
513+ expect ( executeCommandMock ) . toHaveBeenNthCalledWith ( 1 , [
514+ 'git' ,
515+ '-C' ,
516+ '/path/to/repo' ,
517+ 'log' ,
518+ 'HEAD' ,
519+ '-n' ,
520+ '10' ,
521+ '--format=%H|%an|%ae|%at|%s'
522+ ] , { env : { } } )
523+ } )
470524 } )
471525
472526 describe ( 'getCommit' , ( ) => {
0 commit comments