@@ -11,6 +11,7 @@ import {
1111} from './testrepo' ;
1212import { Processor } from './processor' ;
1313import { execAsync , sleep } from './tools' ;
14+ import { rimraf } from 'rimraf' ;
1415
1516describe ( 'Git Repository Tests' , ( ) => {
1617 beforeEach ( async ( ) => {
@@ -245,4 +246,44 @@ describe('Git Repository Tests', () => {
245246 expect ( await fs . exists ( path . join ( getTestRepoPath ( 'merged' ) , 'only-base.txt' ) ) ) . toBe ( false ) ;
246247 expect ( await fs . exists ( path . join ( getTestRepoPath ( 'base' ) , 'only-base.txt' ) ) ) . toBe ( false ) ;
247248 } ) ;
249+
250+ test ( 'Git merge' , async ( ) => {
251+ await execAsync ( 'git checkout -b feature' , { cwd : getTestRepoPath ( 'base' ) } ) ;
252+ await createTestCommit ( getTestRepoPath ( 'base' ) , 'feature1.txt' , 'feature1' , 'base' , 'feature1' ) ;
253+
254+ await sleep ( 1100 ) ;
255+ await execAsync ( 'git checkout master' , { cwd : getTestRepoPath ( 'base' ) } ) ;
256+ await createTestCommit ( getTestRepoPath ( 'base' ) , 'master1.txt' , 'master1' , 'base' , 'master1' ) ;
257+
258+ await sleep ( 1100 ) ;
259+ await execAsync ( 'git checkout feature' , { cwd : getTestRepoPath ( 'base' ) } ) ;
260+ await createTestCommit ( getTestRepoPath ( 'base' ) , 'feature2.txt' , 'feature2' , 'base' , 'feature2' ) ;
261+
262+ await beforeDiflow ( ) ;
263+
264+ const processor1 = new Processor ( getTestRepoPath ( 'config' ) , path . join ( __dirname , 'workrepos' ) , 'master' ) ;
265+ await processor1 . process ( ) ;
266+
267+ await afterDiflow ( ) ;
268+
269+ await checkStateInConfig ( ) ;
270+
271+ await sleep ( 1100 ) ;
272+ await execAsync ( 'git checkout master' , { cwd : getTestRepoPath ( 'base' ) } ) ;
273+ await execAsync ( 'git merge feature' , { cwd : getTestRepoPath ( 'base' ) } ) ;
274+
275+ await beforeDiflow ( 'tmp2' ) ;
276+
277+ await rimraf ( path . join ( __dirname , 'workrepos' ) ) ;
278+ const processor2 = new Processor ( getTestRepoPath ( 'config' ) , path . join ( __dirname , 'workrepos' ) , 'master' ) ;
279+ await processor2 . process ( ) ;
280+
281+ await afterDiflow ( ) ;
282+
283+ await checkStateInConfig ( ) ;
284+
285+ expect ( await fs . exists ( path . join ( getTestRepoPath ( 'merged' ) , 'feature1.txt' ) ) ) . toBe ( true ) ;
286+ expect ( await fs . exists ( path . join ( getTestRepoPath ( 'merged' ) , 'feature2.txt' ) ) ) . toBe ( true ) ;
287+ expect ( await fs . exists ( path . join ( getTestRepoPath ( 'merged' ) , 'master1.txt' ) ) ) . toBe ( true ) ;
288+ } ) ;
248289} ) ;
0 commit comments