Search in sources :

Example 1 with GitilesAccess

use of com.google.gitiles.GitilesAccess in project gitiles by GerritCodeReview.

the class BlameServlet method doGetHtml.

@Override
protected void doGetHtml(HttpServletRequest req, HttpServletResponse res) throws IOException {
    GitilesView view = ViewFilter.getView(req);
    Repository repo = ServletUtils.getRepository(req);
    try (RevWalk rw = new RevWalk(repo)) {
        GitilesAccess access = getAccess(req);
        RegionResult result = getRegions(view, access, repo, rw, res);
        if (result == null) {
            return;
        }
        String title = "Blame - " + view.getPathPart();
        Map<String, ?> blobData = new BlobSoyData(rw.getObjectReader(), view).toSoyData(view.getPathPart(), result.blobId);
        if (blobData.get("lines") != null) {
            DateFormatter df = new DateFormatter(access, Format.ISO);
            renderHtml(req, res, "gitiles.blameDetail", ImmutableMap.of("title", title, "breadcrumbs", view.getBreadcrumbs(), "data", blobData, "regions", toSoyData(view, rw.getObjectReader(), result.regions, df)));
        } else {
            renderHtml(req, res, "gitiles.blameDetail", ImmutableMap.of("title", title, "breadcrumbs", view.getBreadcrumbs(), "data", blobData));
        }
    }
}
Also used : Repository(org.eclipse.jgit.lib.Repository) BlobSoyData(com.google.gitiles.BlobSoyData) GitilesAccess(com.google.gitiles.GitilesAccess) DateFormatter(com.google.gitiles.DateFormatter) GitilesView(com.google.gitiles.GitilesView) RevWalk(org.eclipse.jgit.revwalk.RevWalk)

Aggregations

BlobSoyData (com.google.gitiles.BlobSoyData)1 DateFormatter (com.google.gitiles.DateFormatter)1 GitilesAccess (com.google.gitiles.GitilesAccess)1 GitilesView (com.google.gitiles.GitilesView)1 Repository (org.eclipse.jgit.lib.Repository)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1