@@ -204,6 +204,23 @@ test('gets changed files for git', async () => {
204204 . map ( filePath => path . basename ( filePath ) )
205205 . sort ( ) ,
206206 ) . toEqual ( [ 'file1.txt' , 'file4.txt' ] ) ;
207+
208+ run ( `${ GIT } checkout HEAD^^ -b feature-branch` , DIR ) ;
209+
210+ writeFiles ( DIR , {
211+ 'file5.txt' : 'file5' ,
212+ } ) ;
213+ run ( `${ GIT } commit -am "test5"` , DIR ) ;
214+
215+ ( { changedFiles : files } = await getChangedFilesForRoots ( roots , {
216+ sinceCommit : 'master' ,
217+ } ) ) ;
218+ // Returns files from this branch but not ones that only exist on master
219+ expect (
220+ Array . from ( files )
221+ . map ( filePath => path . basename ( filePath ) )
222+ . sort ( ) ,
223+ ) . toEqual ( [ 'file5.txt' ] ) ;
207224} ) ;
208225
209226test ( 'gets changed files for hg' , async ( ) => {
@@ -274,4 +291,35 @@ test('gets changed files for hg', async () => {
274291 . map ( filePath => path . basename ( filePath ) )
275292 . sort ( ) ,
276293 ) . toEqual ( [ 'file1.txt' , 'file4.txt' ] ) ;
294+
295+ run ( `${ HG } commit -m "test3"` , DIR ) ;
296+
297+ ( { changedFiles : files } = await getChangedFilesForRoots ( roots , {
298+ sinceCommit : '-2' ,
299+ } ) ) ;
300+ // Returns files from the last 2 commits
301+ expect (
302+ Array . from ( files )
303+ . map ( filePath => path . basename ( filePath ) )
304+ . sort ( ) ,
305+ ) . toEqual ( [ 'file1.txt' , 'file4.txt' ] ) ;
306+
307+ run ( `${ HG } bookmark master` , DIR ) ;
308+ // Back up and develop on a different branch
309+ run ( `${ HG } checkout --rev=-2` , DIR ) ;
310+
311+ writeFiles ( DIR , {
312+ 'file5.txt' : 'file5' ,
313+ } ) ;
314+ run ( `${ HG } commit -am "test5"` , DIR ) ;
315+
316+ ( { changedFiles : files } = await getChangedFilesForRoots ( roots , {
317+ sinceCommit : 'master' ,
318+ } ) ) ;
319+ // Returns files from this branch but not ones that only exist on master
320+ expect (
321+ Array . from ( files )
322+ . map ( filePath => path . basename ( filePath ) )
323+ . sort ( ) ,
324+ ) . toEqual ( [ 'file5.txt' ] ) ;
277325} ) ;
0 commit comments