Search in sources :

Example 1 with DiffSummary

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

the class ChangeData method filePaths.

public List<String> filePaths(PatchSet ps) throws OrmException {
    Integer psId = ps.getPatchSetId();
    List<String> r = initFiles().get(psId);
    if (r == null) {
        Change c = change();
        if (c == null) {
            return null;
        }
        Optional<DiffSummary> p = getDiffSummary(c, ps);
        if (!p.isPresent()) {
            List<String> emptyFileList = Collections.emptyList();
            if (lazyLoad) {
                files.put(ps.getPatchSetId(), emptyFileList);
            }
            return emptyFileList;
        }
        r = p.get().getPaths();
        files.put(psId, r);
    }
    return r;
}
Also used : Change(com.google.gerrit.reviewdb.client.Change) DiffSummary(com.google.gerrit.server.patch.DiffSummary)

Example 2 with DiffSummary

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

the class ChangeData method computeChangedLines.

private Optional<ChangedLines> computeChangedLines() throws OrmException {
    Change c = change();
    if (c == null) {
        return Optional.empty();
    }
    PatchSet ps = currentPatchSet();
    if (ps == null) {
        return Optional.empty();
    }
    Optional<DiffSummary> ds = getDiffSummary(c, ps);
    if (ds.isPresent()) {
        return Optional.of(ds.get().getChangedLines());
    }
    return Optional.empty();
}
Also used : PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) DiffSummary(com.google.gerrit.server.patch.DiffSummary)

Example 3 with DiffSummary

use of com.google.gerrit.server.patch.DiffSummary 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

DiffSummary (com.google.gerrit.server.patch.DiffSummary)3 Change (com.google.gerrit.reviewdb.client.Change)2 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1 DiffSummaryKey (com.google.gerrit.server.patch.DiffSummaryKey)1 HashSet (java.util.HashSet)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1