Search in sources :

Example 1 with VcsCommitMetadata

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);
        }
    });
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) VcsCommitMetadata(com.intellij.vcs.log.VcsCommitMetadata) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with VcsCommitMetadata

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;
}
Also used : VcsCommitMetadata(com.intellij.vcs.log.VcsCommitMetadata)

Aggregations

VcsCommitMetadata (com.intellij.vcs.log.VcsCommitMetadata)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VcsException (com.intellij.openapi.vcs.VcsException)1 NotNull (org.jetbrains.annotations.NotNull)1