use of com.intellij.vcs.log.VcsCommitMetadata in project intellij-community by JetBrains.
the class GithubCreatePullRequestWorker method getDefaultDescriptionMessage.
@NotNull
public Couple<String> getDefaultDescriptionMessage(@NotNull final BranchInfo branch) {
Couple<String> message = branch.getDefaultMessage();
if (message != null)
return message;
if (branch.getForkInfo().getRemoteName() == null) {
return getSimpleDefaultDescriptionMessage(branch);
}
return GithubUtil.computeValueInModal(myProject, "Collecting last commits...", true, indicator -> {
String localBranch = myCurrentBranch;
String targetBranch = branch.getForkInfo().getRemoteName() + "/" + branch.getRemoteName();
try {
List<VcsCommitMetadata> commits = GitHistoryUtils.readLastCommits(myProject, myGitRepository.getRoot(), localBranch, targetBranch);
if (commits == null)
return getSimpleDefaultDescriptionMessage(branch);
VcsCommitMetadata localCommit = commits.get(0);
VcsCommitMetadata targetCommit = commits.get(1);
if (localCommit.getParents().contains(targetCommit.getId())) {
return GithubUtil.getGithubLikeFormattedDescriptionMessage(localCommit.getFullMessage());
}
return getSimpleDefaultDescriptionMessage(branch);
} catch (ProcessCanceledException e) {
return getSimpleDefaultDescriptionMessage(branch);
} catch (VcsException e) {
GithubNotifications.showWarning(myProject, "Can't collect additional data", e);
return getSimpleDefaultDescriptionMessage(branch);
}
});
}
use of com.intellij.vcs.log.VcsCommitMetadata in project intellij-community by JetBrains.
the class TopCommitsCache method storeDetails.
public void storeDetails(@NotNull List<? extends VcsCommitMetadata> sortedDetails) {
List<VcsCommitMetadata> newDetails = ContainerUtil.filter(sortedDetails, metadata -> !myCache.containsValue(metadata));
if (newDetails.isEmpty())
return;
Iterator<VcsCommitMetadata> it = new MergingIterator(mySortedDetails, newDetails);
List<VcsCommitMetadata> result = ContainerUtil.newArrayList();
boolean isBroken = false;
while (it.hasNext()) {
VcsCommitMetadata detail = it.next();
int index = getIndex(detail);
if (index == VcsLogStorageImpl.NO_INDEX) {
isBroken = true;
// means some error happened (and reported) earlier, nothing we can do here
continue;
}
if (result.size() < VcsLogData.RECENT_COMMITS_COUNT * 2) {
result.add(detail);
myCache.put(index, detail);
} else {
myCache.remove(index);
}
}
assert result.size() == myCache.size() || isBroken : result.size() + " details to store, yet " + myCache.size() + " indexes in cache.";
mySortedDetails = result;
}
Aggregations