private List<DashboardInfo> scanDashboards( Project definingProject, Repository git, RevWalk rw, Ref ref, String project, boolean setDefault) throws IOException { List<DashboardInfo> list = new ArrayList<>(); try (TreeWalk tw = new TreeWalk(rw.getObjectReader())) { tw.addTree(rw.parseTree(ref.getObjectId())); tw.setRecursive(true); while (tw.next()) { if (tw.getFileMode(0) == FileMode.REGULAR_FILE) { try { list.add( DashboardsCollection.parse( definingProject, ref.getName().substring(REFS_DASHBOARDS.length()), tw.getPathString(), new BlobBasedConfig(null, git, tw.getObjectId(0)), project, setDefault)); } catch (ConfigInvalidException e) { log.warn( String.format( "Cannot parse dashboard %s:%s:%s: %s", definingProject.getName(), ref.getName(), tw.getPathString(), e.getMessage())); } } } } return list; }
/** * Returns the list of submodules for this repository. * * @param repository * @param commit * @return list of submodules */ public static List<SubmoduleModel> getSubmodules(Repository repository, RevTree tree) { List<SubmoduleModel> list = new ArrayList<SubmoduleModel>(); byte[] blob = getByteContent(repository, tree, ".gitmodules", false); if (blob == null) { return list; } try { BlobBasedConfig config = new BlobBasedConfig(repository.getConfig(), blob); for (String module : config.getSubsections("submodule")) { String path = config.getString("submodule", module, "path"); String url = config.getString("submodule", module, "url"); list.add(new SubmoduleModel(module, path, url)); } } catch (ConfigInvalidException e) { LOGGER.error("Failed to load .gitmodules file for " + repository.getDirectory(), e); } return list; }
/** * Returns the list of submodules for this repository. * * @param repository * @param commit * @return list of submodules */ public static List<SubmoduleModel> getSubmodules(Repository repository, RevTree tree) { List<SubmoduleModel> list = new ArrayList<SubmoduleModel>(); byte [] blob = getByteContent(repository, tree, ".gitmodules", false); if (blob == null) { return list; } try { BlobBasedConfig config = new BlobBasedConfig(repository.getConfig(), blob); for (String module : config.getSubsections("submodule")) { String path = config.getString("submodule", module, "path"); String url = config.getString("submodule", module, "url"); list.add(new SubmoduleModel(module, path, url)); } } catch (ConfigInvalidException e) { LOGGER.error("Failed to load .gitmodules file for " + repository.getDirectory(), e); } return list; }