Skip to content

Commit 657bc57

Browse files
author
John Haley
committed
Flattened out promise chain in diff.before
1 parent 0485647 commit 657bc57

1 file changed

Lines changed: 31 additions & 30 deletions

File tree

test/tests/diff.js

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,42 @@ describe("Diff", function() {
1616
diffFilename
1717
);
1818

19-
before(function(done) {
19+
before(function() {
2020
var test = this;
2121

2222
return Repository.open(reposPath).then(function(repository) {
2323
test.repository = repository;
2424

25-
return repository.getBranchCommit("master").then(function(masterCommit) {
26-
27-
return masterCommit.getTree().then(function(tree) {
28-
test.masterCommitTree = tree;
29-
30-
return repository.getCommit(oid).then(function(commit) {
31-
test.commit = commit;
32-
33-
return commit.getDiff().then(function(diff) {
34-
test.diff = diff;
35-
36-
fse.writeFile(diffFilepath, "1 line\n2 line\n3 line\n\n4")
37-
.then(function() {
38-
Diff.treeToWorkdirWithIndex(
39-
test.repository,
40-
test.masterCommitTree,
41-
normalizeOptions({
42-
flags: Diff.OPTION.INCLUDE_UNTRACKED
43-
}, NodeGit.DiffOptions)
44-
)
45-
.then(function(workdirDiff) {
46-
test.workdirDiff = workdirDiff;
47-
done();
48-
});
49-
});
50-
});
51-
});
52-
});
53-
});
25+
return repository.getBranchCommit("master");
26+
})
27+
.then(function(masterCommit) {
28+
return masterCommit.getTree();
29+
})
30+
.then(function(tree) {
31+
test.masterCommitTree = tree;
32+
33+
return test.repository.getCommit(oid);
34+
})
35+
.then(function(commit) {
36+
test.commit = commit;
37+
38+
return commit.getDiff();
39+
}).then(function(diff) {
40+
test.diff = diff;
41+
42+
return fse.writeFile(diffFilepath, "1 line\n2 line\n3 line\n\n4");
43+
})
44+
.then(function() {
45+
return Diff.treeToWorkdirWithIndex(
46+
test.repository,
47+
null,
48+
normalizeOptions({
49+
flags: Diff.OPTION.INCLUDE_UNTRACKED
50+
}, NodeGit.DiffOptions)
51+
)
52+
})
53+
.then(function(workdirDiff) {
54+
test.workdirDiff = workdirDiff;
5455
});
5556
});
5657

0 commit comments

Comments
 (0)