/** * Repository may be created without gh connection, but trigger logic expects this fields. * Should be called before trigger logic starts checks. */ public synchronized void actualise(@Nonnull GHRepository ghRepository, @Nonnull TaskListener listener) throws IOException { changed = false; PrintStream logger = listener.getLogger(); // just in case your organisation decided to change domain // take into account only repo/name if (isNull(fullName) || !fullName.equalsIgnoreCase(ghRepository.getFullName())) { logger.printf("Repository full name changed from '%s' to '%s'.\n", fullName, ghRepository.getFullName()); fullName = ghRepository.getFullName(); changed = true; } if (isNull(githubUrl) || !githubUrl.toExternalForm().equalsIgnoreCase(ghRepository.getHtmlUrl().toExternalForm())) { logger.printf("Changing GitHub url from '%s' to '%s'.\n", githubUrl, ghRepository.getHtmlUrl()); githubUrl = ghRepository.getHtmlUrl(); } if (isNull(gitUrl) || !gitUrl.equalsIgnoreCase(ghRepository.getGitTransportUrl())) { logger.printf("Changing Git url from '%s' to '%s'.\n", gitUrl, ghRepository.getGitTransportUrl()); gitUrl = ghRepository.getGitTransportUrl(); } if (isNull(sshUrl) || !sshUrl.equalsIgnoreCase(ghRepository.getSshUrl())) { logger.printf("Changing SSH url from '%s' to '%s'.\n", sshUrl, ghRepository.getSshUrl()); sshUrl = ghRepository.getSshUrl(); } actualiseOnChange(ghRepository, listener); }
public void scanRepository(GHRepository repo) { logger.info("scanning repo: {}", repo.getName()); ObjectNode n = mapper.createObjectNode(); n.put("name", repo.getName()); n.put("description", repo.getDescription()); n.put("fullName", repo.getFullName()); n.put("homepage", repo.getHomepage()); n.put("sshUrl", repo.getSshUrl()); if (repo.getHtmlUrl() != null) { n.put("htmlUrl", repo.getHtmlUrl().toString()); } n.put("url", repo.getUrl().toString()); n.put("gitTransportUrl", repo.getGitTransportUrl()); String cypher = "merge (r:SCMRepo:GitHubRepo {url:{url}}) set r+={props},r.updateTs=timestamp() return r"; getProjector().getNeoRxClient().execCypher(cypher, "url", repo.getUrl().toString(), "props", n); }
/** * 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 GithubRepository(GHRepository repository) { this.repository = repository; URL htmlUrl = repository.getHtmlUrl(); if (htmlUrl != null) { setHtmlUrl(htmlUrl.toString()); } setName(repository.getName()); setCloneUrl(repository.getGitTransportUrl()); }
/** * Returns the local repository for the given GHRepository with matching transport url */ public static LocalRepository findRepository(List<LocalRepository> localRepositories, GHRepository ghRepository) { if (localRepositories != null) { for (LocalRepository repository : localRepositories) { GitRepository repo = repository.getRepo(); if (repo != null) { if (Objects.equal(repo.getCloneUrl(), ghRepository.getGitTransportUrl())) { return repository; } } } } return null; }
public GithubRepository(GHRepository repository) { this.repository = repository; URL htmlUrl = repository.getHtmlUrl(); if (htmlUrl != null) { setHtmlUrl(htmlUrl.toString()); } setName(repository.getName()); setCloneUrl(repository.getGitTransportUrl()); }
@Override public boolean hasCloneUrl(String url) { if (super.hasCloneUrl(url)) { return true; } return Strings.equalAnyValue(url, repository.getGitTransportUrl(), repository.gitHttpTransportUrl(), repository.getSshUrl(), repository.getUrl(), repository.getSvnUrl()); }
@Override public boolean hasCloneUrl(String url) { if (super.hasCloneUrl(url)) { return true; } return Strings.equalAnyValue(url, repository.getGitTransportUrl(), repository.gitHttpTransportUrl(), repository.getSshUrl(), repository.getUrl(), repository.getSvnUrl()); }