@@ -191,6 +191,37 @@ test('gets changed files for git', async () => {
191191 . map ( filePath => path . basename ( filePath ) )
192192 . sort ( ) ,
193193 ) . toEqual ( [ 'file1.txt' , 'file4.txt' ] ) ;
194+
195+ run ( `${ GIT } add file4.txt` , DIR ) ;
196+ run ( `${ GIT } commit -m "test3"` , DIR ) ;
197+
198+ ( { changedFiles : files } = await getChangedFilesForRoots ( roots , {
199+ changedSince : 'HEAD^^' ,
200+ } ) ) ;
201+ // Returns files from the last 2 commits
202+ expect (
203+ Array . from ( files )
204+ . map ( filePath => path . basename ( filePath ) )
205+ . sort ( ) ,
206+ ) . 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 } add file5.txt` , DIR ) ;
214+ run ( `${ GIT } commit -m "test5"` , DIR ) ;
215+
216+ ( { changedFiles : files } = await getChangedFilesForRoots ( roots , {
217+ changedSince : 'master' ,
218+ } ) ) ;
219+ // Returns files from this branch but not ones that only exist on master
220+ expect (
221+ Array . from ( files )
222+ . map ( filePath => path . basename ( filePath ) )
223+ . sort ( ) ,
224+ ) . toEqual ( [ 'file5.txt' ] ) ;
194225} ) ;
195226
196227test ( 'gets changed files for hg' , async ( ) => {
@@ -261,4 +292,37 @@ test('gets changed files for hg', async () => {
261292 . map ( filePath => path . basename ( filePath ) )
262293 . sort ( ) ,
263294 ) . toEqual ( [ 'file1.txt' , 'file4.txt' ] ) ;
295+
296+ run ( `${ HG } add file4.txt` , DIR ) ;
297+ run ( `${ HG } commit -m "test3"` , DIR ) ;
298+
299+ ( { changedFiles : files } = await getChangedFilesForRoots ( roots , {
300+ changedSince : '-3' ,
301+ } ) ) ;
302+ // Returns files from the last 2 commits
303+ expect (
304+ Array . from ( files )
305+ . map ( filePath => path . basename ( filePath ) )
306+ . sort ( ) ,
307+ ) . toEqual ( [ 'file1.txt' , 'file4.txt' ] ) ;
308+
309+ run ( `${ HG } bookmark master` , DIR ) ;
310+ // Back up and develop on a different branch
311+ run ( `${ HG } checkout --rev=-2` , DIR ) ;
312+
313+ writeFiles ( DIR , {
314+ 'file5.txt' : 'file5' ,
315+ } ) ;
316+ run ( `${ HG } add file5.txt` , DIR ) ;
317+ run ( `${ HG } commit -m "test4"` , DIR ) ;
318+
319+ ( { changedFiles : files } = await getChangedFilesForRoots ( roots , {
320+ changedSince : 'master' ,
321+ } ) ) ;
322+ // Returns files from this branch but not ones that only exist on master
323+ expect (
324+ Array . from ( files )
325+ . map ( filePath => path . basename ( filePath ) )
326+ . sort ( ) ,
327+ ) . toEqual ( [ 'file5.txt' ] ) ;
264328} ) ;
0 commit comments