Skip to content

Commit 4c8f601

Browse files
author
John Haley
committed
First round of test fixes
1 parent 1cd6320 commit 4c8f601

11 files changed

+328
-209
lines changed

examples/merge-cleanly.js

+1-1
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

+6
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,12 @@
982982
"isErrorCode": true
983983
}
984984
},
985+
"git_index_add_bypath": {
986+
"isAsync": true,
987+
"return": {
988+
"isErrorCode": true
989+
}
990+
},
985991
"git_index_add_frombuffer": {
986992
"ignore": true
987993
},

lib/repository.js

+26-14
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,13 @@ Repository.prototype.createCommitOnHead = function(
549549
.then(function() {
550550
return index.addByPath(filePath);
551551
});
552-
}, Promise.resolve());
553-
index.write();
554-
return index.writeTree();
552+
}, Promise.resolve())
553+
.then(function() {
554+
return index.write();
555+
})
556+
.then(function() {
557+
return index.writeTree();
558+
});
555559
})
556560
.then(function(treeOid) {
557561
return repo.getHeadCommit()
@@ -854,7 +858,6 @@ Repository.prototype.mergeBranches =
854858
}
855859

856860
// No conflicts so just go ahead with the merge
857-
index.write();
858861
return index.writeTreeTo(repo);
859862
})
860863
.then(function(oid) {
@@ -1292,15 +1295,20 @@ Repository.prototype.stageFilemode = function(filePath, stageNew) {
12921295
return Promise.reject("No differences found for this file.");
12931296
}
12941297

1295-
pathPatches.forEach(function(pathPatch) {
1296-
var entry = index.getByPath(pathPatch.newFile().path(), 0);
1297-
1298-
entry.mode = stageNew ?
1299-
pathPatch.newFile().mode() : pathPatch.oldFile().mode();
1298+
return pathPatches
1299+
.reduce(function(lastIndexAddPromise, pathPatch) {
1300+
var entry = index.getByPath(pathPatch.newFile().path(), 0);
13001301

1301-
index.add(entry);
1302-
});
1302+
entry.mode = stageNew ?
1303+
pathPatch.newFile().mode() : pathPatch.oldFile().mode();
13031304

1305+
return lastIndexAddPromise
1306+
.then(function() {
1307+
return index.add(entry);
1308+
});
1309+
}, Promise.resolve());
1310+
})
1311+
.then(function() {
13041312
return index.write();
13051313
});
13061314
};
@@ -1461,8 +1469,10 @@ Repository.prototype.stageLines =
14611469
!pathPatch[0].isTypeChange();
14621470
}
14631471
if (emptyPatch) {
1464-
index.addByPath(filePath);
1465-
return index.write();
1472+
return index.addByPath(filePath)
1473+
.then(function() {
1474+
return index.write();
1475+
});
14661476
} else {
14671477
return result;
14681478
}
@@ -1514,7 +1524,9 @@ Repository.prototype.stageLines =
15141524
entry.path = filePath;
15151525
entry.fileSize = newBlob.content().length;
15161526

1517-
index.add(entry);
1527+
return index.add(entry);
1528+
})
1529+
.then(function() {
15181530
return index.write();
15191531
})
15201532
.then(function(result) {

test/tests/checkout.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ describe("Checkout", function() {
128128

129129
return test.repository.refreshIndex()
130130
.then(function(index) {
131-
index.addByPath(packageJsonName);
132-
index.write();
133-
134-
return index.writeTree();
131+
return index.addByPath(packageJsonName)
132+
.then(function() {
133+
return index.write();
134+
})
135+
.then(function() {
136+
return index.writeTree();
137+
});
135138
});
136139
})
137140
.then(function(oid) {

test/tests/cherrypick.js

-2
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/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe("Index", function() {
8080
}));
8181
})
8282
.then(function() {
83-
index.clear();
83+
return index.clear();
8484
});
8585
});
8686

@@ -131,7 +131,7 @@ describe("Index", function() {
131131
}));
132132
})
133133
.then(function() {
134-
index.clear();
134+
return index.clear();
135135
});
136136
});
137137

0 commit comments

Comments
 (0)