Search in sources :

Example 1 with DiffSummaryKey

use of com.google.gerrit.server.patch.DiffSummaryKey in project gerrit by GerritCodeReview.

the class ChangeData method getDiffSummary.

private Optional<DiffSummary> getDiffSummary() {
    if (diffSummary == null) {
        if (!lazyload()) {
            return Optional.empty();
        }
        Change c = change();
        PatchSet ps = currentPatchSet();
        if (c == null || ps == null || !loadCommitData()) {
            return Optional.empty();
        }
        PatchListKey pk = PatchListKey.againstBase(ps.commitId(), parentCount);
        DiffSummaryKey key = DiffSummaryKey.fromPatchListKey(pk);
        try {
            diffSummary = Optional.of(patchListCache.getDiffSummary(key, c.getProject()));
        } catch (PatchListNotAvailableException e) {
            diffSummary = Optional.empty();
        }
    }
    return diffSummary;
}
Also used : PatchListNotAvailableException(com.google.gerrit.server.patch.PatchListNotAvailableException) PatchSet(com.google.gerrit.entities.PatchSet) Change(com.google.gerrit.entities.Change) PatchListKey(com.google.gerrit.server.patch.PatchListKey) DiffSummaryKey(com.google.gerrit.server.patch.DiffSummaryKey)

Example 2 with DiffSummaryKey

use of com.google.gerrit.server.patch.DiffSummaryKey in project gerrit by GerritCodeReview.

the class PostReview method getAffectedFilePaths.

private Set<String> getAffectedFilePaths(RevisionResource revision) throws PatchListNotAvailableException {
    ObjectId newId = revision.getPatchSet().commitId();
    DiffSummaryKey key = DiffSummaryKey.fromPatchListKey(PatchListKey.againstDefaultBase(newId, Whitespace.IGNORE_NONE));
    DiffSummary ds = patchListCache.getDiffSummary(key, revision.getProject());
    return new HashSet<>(ds.getPaths());
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) DiffSummary(com.google.gerrit.server.patch.DiffSummary) DiffSummaryKey(com.google.gerrit.server.patch.DiffSummaryKey) HashSet(java.util.HashSet)

Aggregations

DiffSummaryKey (com.google.gerrit.server.patch.DiffSummaryKey)2 Change (com.google.gerrit.entities.Change)1 PatchSet (com.google.gerrit.entities.PatchSet)1 DiffSummary (com.google.gerrit.server.patch.DiffSummary)1 PatchListKey (com.google.gerrit.server.patch.PatchListKey)1 PatchListNotAvailableException (com.google.gerrit.server.patch.PatchListNotAvailableException)1 HashSet (java.util.HashSet)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1