use of com.virtuslab.gitmachete.frontend.graph.impl.items.BranchItem 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);
}
use of com.virtuslab.gitmachete.frontend.graph.impl.items.BranchItem in project git-machete-intellij-plugin by VirtusLab.
the class RepositoryGraphBuilder method addRootBranch.
private void addRootBranch(java.util.List<IGraphItem> graphItems, IRootManagedBranchSnapshot branch) {
BranchItem branchItem = createBranchItemFor(branch, /* prevSiblingItemIndex */
-1, GraphItemColor.GREEN, /* indentLevel */
0);
graphItems.add(branchItem);
}
use of com.virtuslab.gitmachete.frontend.graph.impl.items.BranchItem in project git-machete-intellij-plugin by VirtusLab.
the class RepositoryGraphBuilder method createBranchItemFor.
/**
* @return {@link BranchItem} for given properties and provide additional attributes if the branch is the current one
*/
private BranchItem createBranchItemFor(IManagedBranchSnapshot branch, @GTENegativeOne int prevSiblingItemIndex, GraphItemColor graphItemColor, @NonNegative int indentLevel) {
RelationToRemote relationToRemote = branch.getRelationToRemote();
Option<IManagedBranchSnapshot> currentBranch = repositorySnapshot.getCurrentBranchIfManaged();
boolean isCurrentBranch = currentBranch.isDefined() && currentBranch.get().equals(branch);
boolean hasChildItem = !branch.getChildren().isEmpty();
return new BranchItem(branch, graphItemColor, relationToRemote, prevSiblingItemIndex, indentLevel, isCurrentBranch, hasChildItem);
}
Aggregations