/** * Iterates through all projects in the given github organisation and generates an archetype for it */ public void generateArchetypesFromGithubOrganisation(String githubOrg, File outputDir, List<String> dirs) throws IOException { GitHub github = GitHub.connectAnonymously(); GHOrganization organization = github.getOrganization(githubOrg); Objects.notNull(organization, "No github organisation found for: " + githubOrg); Map<String, GHRepository> repositories = organization.getRepositories(); Set<Map.Entry<String, GHRepository>> entries = repositories.entrySet(); File cloneParentDir = new File(outputDir, "../git-clones"); if (cloneParentDir.exists()) { Files.recursiveDelete(cloneParentDir); } for (Map.Entry<String, GHRepository> entry : entries) { String repoName = entry.getKey(); GHRepository repo = entry.getValue(); String url = repo.getGitTransportUrl(); generateArchetypeFromGitRepo(outputDir, dirs, cloneParentDir, repoName, url, null); } }
public void scanOrganization(GHOrganization org) { try { ObjectNode n = mapper.createObjectNode(); n.put("url", org.getUrl().toString()); if (org.getHtmlUrl() != null) { n.put("htmlUrl", org.getHtmlUrl().toString()); } n.put("name", org.getLogin()); n.put("displayName", org.getName()); String cypher = "merge (o:GitHubOrg {url:{url}}) set o+={props},o.updateTs=timestamp() return o"; getProjector().getNeoRxClient().execCypher(cypher, "url", n.path("url").asText(), "props", n); } catch (IOException e) { throw new MercatorException(e); } try { org.getRepositories().values().forEach(repo -> { scanRepository(repo); String cypher = "match (o:GitHubOrg {url:{orgUrl}}), (r:GitHubRepo {url:{repoUrl}}) merge (o)-[x:CONTAINS]->(r) set x.updateTs=timestamp()"; getProjector().getNeoRxClient().execCypher(cypher, "orgUrl", org.getUrl().toString(), "repoUrl", repo.getUrl().toString()); }); } catch (IOException e) { throw new MercatorException(e); } }