X Tutup
Skip to content

Commit 03496d8

Browse files
committed
Merge pull request #847 from pevers/master
Fixed example walk-history-for-file.js
2 parents f7f9c87 + db1fc68 commit 03496d8

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

examples/walk-history-for-file.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,19 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
1717
history.on("commit", function(commit) {
1818
return commit.getDiff()
1919
.then(function(diffList) {
20-
var addCommit = diffList.reduce(function(prevVal, diff) {
21-
var result =
22-
prevVal ||
23-
diff.patches().reduce(function(prevValDiff, patch) {
24-
25-
var result =
26-
prevValDiff ||
27-
!!~patch.oldFile().path().indexOf("descriptor.json") ||
28-
!!~patch.newFile().path().indexOf("descriptor.json");
29-
30-
return result;
31-
}, false);
32-
33-
return result;
34-
}, false);
35-
36-
if (addCommit) {
37-
commits.push(commit);
38-
}
20+
diffList.map(function(diff) {
21+
diff.patches().then(function(patches) {
22+
patches.map(function(patch) {
23+
var result =
24+
!!~patch.oldFile().path().indexOf("descriptor.json") ||
25+
!!~patch.newFile().path().indexOf("descriptor.json");
26+
27+
if(result && !~commits.indexOf(commit)) {
28+
commits.push(commit);
29+
}
30+
});
31+
});
32+
});
3933
});
4034
});
4135

0 commit comments

Comments
 (0)
X Tutup