use of com.virtuslab.gitmachete.backend.api.ICommitOfManagedBranch in project git-machete-intellij-plugin by VirtusLab.
the class RepositoryGraphBuilder method buildCommitsAndNonRootBranch.
private void buildCommitsAndNonRootBranch(java.util.List<IGraphItem> graphItems, INonRootManagedBranchSnapshot branch, @NonNegative int parentBranchIndex, @NonNegative int indentLevel) {
List<ICommitOfManagedBranch> commits = branchGetCommitsStrategy.getCommitsOf(branch).reverse();
val syncToParentStatus = branch.getSyncToParentStatus();
GraphItemColor graphItemColor = getGraphItemColor(syncToParentStatus);
int branchItemIndex = graphItems.size() + commits.size();
// We are building some non root branch here so some root branch item has been added already.
assert branchItemIndex > 0 : "Branch node index is not greater than 0 but should be";
boolean isFirstItemInBranch = true;
for (ICommitOfManagedBranch commit : commits) {
int lastItemIndex = graphItems.size() - 1;
// We are building some non root branch here so some root branch item has been added already.
assert lastItemIndex >= 0 : "Last node index is less than 0 but shouldn't be";
int prevSiblingItemIndex = isFirstItemInBranch ? parentBranchIndex : lastItemIndex;
int nextSiblingItemIndex = graphItems.size() + 1;
val c = new CommitItem(commit, branch, graphItemColor, prevSiblingItemIndex, nextSiblingItemIndex, indentLevel);
graphItems.add(c);
isFirstItemInBranch = false;
}
int lastItemIndex = graphItems.size() - 1;
/*
* If a branch has no commits (possibly due to commits getting strategy being {@code EMPTY_GET_COMMITS}) its {@code
* prevSiblingItemIndex} is just the {@code parentBranchIndex}. Otherwise the {@code prevSiblingItemIndex} is an index of
* most recently added item (its last commit).
*/
int prevSiblingItemIndex = commits.isEmpty() ? parentBranchIndex : lastItemIndex;
BranchItem branchItem = createBranchItemFor(branch, prevSiblingItemIndex, graphItemColor, indentLevel);
graphItems.add(branchItem);
}
Aggregations