List of usage examples for org.eclipse.jgit.submodule SubmoduleWalk forPath
public static SubmoduleWalk forPath(Repository repository, AbstractTreeIterator iterator, String path) throws IOException
From source file:com.google.gitiles.PathServlet.java
License:Open Source License
private void showGitlink(HttpServletRequest req, HttpServletResponse res, RevWalk rw, TreeWalk tw, RevTree root) throws IOException { GitilesView view = ViewFilter.getView(req); SubmoduleWalk sw = SubmoduleWalk.forPath(ServletUtils.getRepository(req), root, view.getTreePath()); String remoteUrl;//from w ww .j a v a 2s . c om try { remoteUrl = sw.getRemoteUrl(); } catch (ConfigInvalidException e) { throw new IOException(e); } finally { sw.release(); } Map<String, Object> data = Maps.newHashMap(); data.put("sha", ObjectId.toString(tw.getObjectId(0))); data.put("remoteUrl", remoteUrl); // TODO(dborowitz): Guess when we can put commit SHAs in the URL. String httpUrl = resolveHttpUrl(remoteUrl); if (httpUrl != null) { data.put("httpUrl", httpUrl); } // TODO(sop): Allow caching links by SHA-1 when no S cookie is sent. render(req, res, "gitiles.pathDetail", ImmutableMap.of("title", view.getTreePath(), "type", FileType.GITLINK.toString(), "data", data)); }