Search in sources :

Example 1 with ChangeType

use of org.eclipse.jgit.diff.DiffEntry.ChangeType in project gitiles by GerritCodeReview.

the class CommitSoyData method toSoyData.

private static Object toSoyData(GitilesView view, DiffList dl) {
    if (dl.oldRevision == null) {
        return NullData.INSTANCE;
    }
    GitilesView.Builder diffUrl = GitilesView.diff().copyFrom(view).setOldRevision(dl.oldRevision).setRevision(dl.revision).setPathPart("");
    List<Object> result = Lists.newArrayListWithCapacity(dl.entries.size());
    for (DiffEntry e : dl.entries) {
        Map<String, Object> entry = Maps.newHashMapWithExpectedSize(5);
        ChangeType type = e.getChangeType();
        if (type != DELETE) {
            entry.put("path", e.getNewPath());
            entry.put("url", GitilesView.path().copyFrom(view).setRevision(dl.revision).setPathPart(e.getNewPath()).toUrl());
        } else {
            entry.put("path", e.getOldPath());
            entry.put("url", GitilesView.path().copyFrom(view).setRevision(dl.oldRevision).setPathPart(e.getOldPath()).toUrl());
        }
        entry.put("diffUrl", diffUrl.setAnchor("F" + result.size()).toUrl());
        entry.put("changeType", e.getChangeType().toString());
        if (type == COPY || type == RENAME) {
            entry.put("oldPath", e.getOldPath());
        }
        result.add(entry);
    }
    return result;
}
Also used : ChangeType(org.eclipse.jgit.diff.DiffEntry.ChangeType) DiffEntry(org.eclipse.jgit.diff.DiffEntry)

Aggregations

DiffEntry (org.eclipse.jgit.diff.DiffEntry)1 ChangeType (org.eclipse.jgit.diff.DiffEntry.ChangeType)1