Skip to content

Commit 60c84f8

Browse files
author
John Haley
committed
First round of test fixes
1 parent b976516 commit 60c84f8

12 files changed

Lines changed: 328 additions & 246 deletions

File tree

examples/merge-cleanly.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fse.remove(path.resolve(__dirname, repoDir))
8888
.then(function() {
8989
return index.write();
9090
})
91-
.then(funcion() {
91+
.then(function() {
9292
return index.writeTree();
9393
});
9494
})

generate/input/descriptor.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,12 @@
980980
"isErrorCode": true
981981
}
982982
},
983+
"git_index_add_bypath": {
984+
"isAsync": true,
985+
"return": {
986+
"isErrorCode": true
987+
}
988+
},
983989
"git_index_add_frombuffer": {
984990
"ignore": true
985991
},

lib/repository.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,13 @@ Repository.prototype.createCommitOnHead = function(
532532
.then(function() {
533533
return index.addByPath(filePath);
534534
});
535-
}, Promise.resolve());
536-
index.write();
537-
return index.writeTree();
535+
}, Promise.resolve())
536+
.then(function() {
537+
return index.write();
538+
})
539+
.then(function() {
540+
return index.writeTree();
541+
});
538542
})
539543
.then(function(treeOid) {
540544
return repo.getHeadCommit()
@@ -837,7 +841,6 @@ Repository.prototype.mergeBranches =
837841
}
838842

839843
// No conflicts so just go ahead with the merge
840-
index.write();
841844
return index.writeTreeTo(repo);
842845
})
843846
.then(function(oid) {
@@ -1249,7 +1252,6 @@ Repository.prototype.stageFilemode = function(filePath, stageNew) {
12491252
})
12501253
.then(function(indexResult) {
12511254
index = indexResult;
1252-
return index.read(1);
12531255
})
12541256
.then(function() {
12551257
return diffPromise;
@@ -1276,15 +1278,20 @@ Repository.prototype.stageFilemode = function(filePath, stageNew) {
12761278
return Promise.reject("No differences found for this file.");
12771279
}
12781280

1279-
pathPatches.forEach(function(pathPatch) {
1280-
var entry = index.getByPath(pathPatch.newFile().path(), 0);
1281-
1282-
entry.mode = stageNew ?
1283-
pathPatch.newFile().mode() : pathPatch.oldFile().mode();
1281+
return pathPatches
1282+
.reduce(function(lastIndexAddPromise, pathPatch) {
1283+
var entry = index.getByPath(pathPatch.newFile().path(), 0);
12841284

1285-
index.add(entry);
1286-
});
1285+
entry.mode = stageNew ?
1286+
pathPatch.newFile().mode() : pathPatch.oldFile().mode();
12871287

1288+
return lastIndexAddPromise
1289+
.then(function() {
1290+
return index.add(entry);
1291+
});
1292+
}, Promise.resolve());
1293+
})
1294+
.then(function() {
12881295
return index.write();
12891296
});
12901297
};
@@ -1445,8 +1452,10 @@ Repository.prototype.stageLines =
14451452
!pathPatch[0].isTypeChange();
14461453
}
14471454
if (emptyPatch) {
1448-
index.addByPath(filePath);
1449-
return index.write();
1455+
return index.addByPath(filePath)
1456+
.then(function() {
1457+
return index.write();
1458+
});
14501459
} else {
14511460
return result;
14521461
}
@@ -1456,7 +1465,6 @@ Repository.prototype.stageLines =
14561465
return repo.openIndex()
14571466
.then(function(indexResult) {
14581467
index = indexResult;
1459-
return index.read(1);
14601468
})
14611469
.then(function() {
14621470
return diffPromise();
@@ -1499,7 +1507,9 @@ Repository.prototype.stageLines =
14991507
entry.path = filePath;
15001508
entry.fileSize = newBlob.content().length;
15011509

1502-
index.add(entry);
1510+
return index.add(entry);
1511+
})
1512+
.then(function() {
15031513
return index.write();
15041514
})
15051515
.then(function(result) {

test/tests/checkout.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,13 @@ describe("Checkout", function() {
128128

129129
return test.repository.openIndex()
130130
.then(function(index) {
131-
index.read(1);
132-
index.addByPath(packageJsonName);
133-
index.write();
134-
135-
return index.writeTree();
131+
return index.addByPath(packageJsonName)
132+
.then(function() {
133+
return index.write();
134+
})
135+
.then(function() {
136+
return index.writeTree();
137+
});
136138
});
137139
})
138140
.then(function(oid) {

test/tests/cherrypick.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ describe("Cherrypick", function() {
7575
})
7676
.then(function(index) {
7777
assert(index);
78-
index.write();
79-
8078
return index.writeTreeTo(repo);
8179
})
8280
.then(function(oid) {

test/tests/commit.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ describe("Commit", function() {
5959
})
6060
.then(function(indexResult) {
6161
index = indexResult;
62-
return index.read(1);
6362
})
6463
.then(function() {
6564
return index.addByPath(fileName);
@@ -166,7 +165,6 @@ describe("Commit", function() {
166165
})
167166
.then(function(indexResult) {
168167
index = indexResult;
169-
return index.read(1);
170168
})
171169
.then(function() {
172170
return index.addByPath(fileName);
@@ -246,7 +244,6 @@ describe("Commit", function() {
246244
})
247245
.then(function(indexResult) {
248246
index = indexResult;
249-
return index.read(1);
250247
})
251248
.then(function() {
252249
return index.addByPath(fileName);
@@ -294,7 +291,6 @@ describe("Commit", function() {
294291
})
295292
.then(function(indexResult) {
296293
index = indexResult;
297-
return index.read(1);
298294
})
299295
.then(function() {
300296
return index.addByPath(newFileName);

test/tests/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe("Index", function() {
8181
}));
8282
})
8383
.then(function() {
84-
index.clear();
84+
return index.clear();
8585
});
8686
});
8787

@@ -132,7 +132,7 @@ describe("Index", function() {
132132
}));
133133
})
134134
.then(function() {
135-
index.clear();
135+
return index.clear();
136136
});
137137
});
138138

0 commit comments

Comments
 (0)