-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathconflict.spec.js
72 lines (55 loc) · 2.55 KB
/
conflict.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { lgPromise } from './common.js';
import assert from 'assert';
describe('conflicts', function() {
beforeEach(async () => {
console.log('cwd', (await lgPromise).FS.cwd());
});
it('should create 1 bare and 2 clones and create/resolve conflicts', async () => {
const lg = await lgPromise;
const FS = lg.FS;
FS.mkdir('bareconflicts');
FS.chdir('bareconflicts');
lg.callMain(['init', '--bare', '.']);
lg.callMain(['config', 'user.name', 'The Tester']);
lg.callMain(['config', 'user.email', '[email protected]']);
FS.chdir('..');
lg.callMain(['clone', 'bareconflicts', 'testconflicts1']);
FS.chdir('testconflicts1');
lg.callMain(['config', 'user.name', 'The Tester']);
lg.callMain(['config', 'user.email', '[email protected]']);
FS.writeFile('test.txt', 'abcdef');
lg.callMain(['add', 'test.txt']);
lg.callMain(['commit', '-m', 'test commit 1']);
lg.callMain(['push']);
FS.chdir('..');
lg.callMain(['clone', 'bareconflicts', 'testconflicts2']);
FS.chdir('testconflicts1');
FS.writeFile('test.txt', 'abc');
lg.callMain(['add', 'test.txt']);
lg.callMain(['commit', '-m', 'test commit 2']);
lg.callMain(['push']);
FS.chdir('..');
FS.chdir('testconflicts2');
lg.callMain(['config', 'user.name', 'The Tester']);
lg.callMain(['config', 'user.email', '[email protected]']);
FS.writeFile('test.txt', 'hijklmn');
lg.callMain(['add', 'test.txt']);
lg.callMain(['commit', '-m', 'test commit 3']);
try {
lg.callWithOutput(['push']);
assert.fail('should reject pushing');
} catch(e) {
assert.match(e, /cannot push because a reference that you are trying to update on the remote contains commits that are not present locally/)
}
lg.callMain(['fetch','origin']);
lg.callMain(['merge', 'origin/master']);
assert.match(lg.callWithOutput(['status']), /conflict\: a\:test\.txt o\:test\.txt t\:test\.txt/);
FS.writeFile('test.txt', 'abcxyz');
lg.callMain(['add', 'test.txt']);
lg.callMain(['commit', '-m', 'resolved conflict']);
assert.match(lg.callWithOutput(['log']), /resolved conflict/);
assert.match(lg.callWithOutput(['push']),/pushed/);
console.log('status', lg.callWithOutput(['status']));
assert.equal('abcxyz', FS.readFile('test.txt', {encoding: 'utf8'}));
});
});