List of usage examples for org.eclipse.jgit.submodule SubmoduleWalk getRemoteUrl
public String getRemoteUrl() throws IOException, ConfigInvalidException
From source file:com.bacoder.scmtools.git.internal.CloneAndProcessCommand.java
License:Apache License
@Override protected void cloneSubmodules(Repository repository) throws IOException, GitAPIException { SubmoduleWalk generator; if (isInMemory()) { generator = new InMemorySubmoduleWalk(repository, submodulesConfig); try {//from w w w. j a v a 2 s . com DirCache index = repository.readDirCache(); generator.setTree(new DirCacheIterator(index)); } catch (IOException e) { generator.release(); throw e; } } else { generator = SubmoduleWalk.forIndex(repository); } try { while (generator.next()) { if (generator.getConfigUrl() != null) { continue; } String path = generator.getPath(); String url = generator.getRemoteUrl(); CloneAndProcessCommand command = new CloneAndProcessCommand(path, config).setProcessor(processor); command.setURI(url).setCloneSubmodules(true); command.call(); } } catch (ConfigInvalidException e) { throw new IOException("Config invalid", e); } }
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;//w ww . j av a 2 s. c o m 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)); }