Skip to content
This repository has been archived by the owner on Dec 13, 2017. It is now read-only.

Commit

Permalink
Fixes #10, #11.
Browse files Browse the repository at this point in the history
  • Loading branch information
cha55son committed May 20, 2014
1 parent 244a1eb commit 8be2653
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/main/resources/js/commitgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,34 @@
self.branches(branchData[0].values);
self.tags(tagData[0].values);

var commits = masterCommitData[0].values;
var masterCommits = masterCommitData[0].values;
var finalBranchCommits = [];
self.getBranchCommits().then(function(branchCommits) {
// Remove duplicate commits
$.each(commits, function(i, masterCommit) {
// Start at the end so we don't mess up the iterator
for (var j = branchCommits.length - 1; j >= 0; j--)
if (branchCommits[j].id === masterCommit.id)
branchCommits.splice(j, 1);
// Remove duplicate commits issue/#11
$.each(branchCommits, function(i, branchCommit) {
var isDup = false;
$.each(masterCommits.concat(finalBranchCommits), function(j, finalCommit) {
if (branchCommit.id === finalCommit.id) {
isDup = true;
return false;
}
});
if (!isDup)
finalBranchCommits.push(branchCommit);
});
// Merge branch commits into the mainline by timestamp
$.each(branchCommits, function(i, branchCommit) {
$.each(commits, function(j, masterCommit) {
$.each(finalBranchCommits, function(i, branchCommit) {
$.each(masterCommits, function(j, masterCommit) {
if (branchCommit.authorTimestamp < masterCommit.authorTimestamp) return;
commits.splice(j, 0, branchCommit);
masterCommits.splice(j, 0, branchCommit);
return false;
});
});
var debounceFn = _.debounce(function() {
self.buildGraph();
}, 200);
$(window).resize(debounceFn);
self.commits($.map(commits, function(commit) {
self.commits($.map(masterCommits, function(commit) {
return new CommitVM(commit);
}));
self.isLoading(false);
Expand Down

0 comments on commit 8be2653

Please sign in to comment.