Search in sources :

Example 1 with Region

use of com.google.gitiles.blame.Region in project gerrit by GerritCodeReview.

the class GetBlame method blame.

private List<BlameInfo> blame(ObjectId id, String path, Repository repository, RevWalk revWalk) throws IOException {
    ListMultimap<BlameInfo, RangeInfo> ranges = MultimapBuilder.hashKeys().arrayListValues().build();
    List<BlameInfo> result = new ArrayList<>();
    if (blameCache.findLastCommit(repository, id, path) == null) {
        return result;
    }
    List<Region> blameRegions = blameCache.get(repository, id, path);
    int from = 1;
    for (Region region : blameRegions) {
        RevCommit commit = revWalk.parseCommit(region.getSourceCommit());
        BlameInfo blameInfo = toBlameInfo(commit, region.getSourceAuthor());
        ranges.put(blameInfo, new RangeInfo(from, from + region.getCount() - 1));
        from += region.getCount();
    }
    for (BlameInfo key : ranges.keySet()) {
        key.ranges = ranges.get(key);
        result.add(key);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Region(com.google.gitiles.blame.Region) RangeInfo(com.google.gerrit.extensions.common.RangeInfo) BlameInfo(com.google.gerrit.extensions.common.BlameInfo) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

BlameInfo (com.google.gerrit.extensions.common.BlameInfo)1 RangeInfo (com.google.gerrit.extensions.common.RangeInfo)1 Region (com.google.gitiles.blame.Region)1 ArrayList (java.util.ArrayList)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1