/** * Gets all the open pull requests in this organizataion. */ public List<GHPullRequest> getPullRequests() throws IOException { List<GHPullRequest> all = new ArrayList<GHPullRequest>(); for (GHRepository r : getRepositoriesWithOpenPullRequests()) { all.addAll(r.getPullRequests(GHIssueState.OPEN)); } return all; }
/** * Gets all the open pull requests in this organizataion. */ public List<GHPullRequest> getPullRequests() throws IOException { List<GHPullRequest> all = new ArrayList<GHPullRequest>(); for (GHRepository r : getRepositoriesWithOpenPullRequests()) { all.addAll(r.getPullRequests(GHIssueState.OPEN)); } return all; }
/** * Gets all the open pull requests in this organizataion. */ public List<GHPullRequest> getPullRequests() throws IOException { List<GHPullRequest> all = new ArrayList<GHPullRequest>(); for (GHRepository r : getRepositoriesWithOpenPullRequests()) { all.addAll(r.getPullRequests(GHIssueState.OPEN)); } return all; }
private static Stream<GHPullRequest> fetchRemotePRs(GitHubPRRepository localRepo, GHRepository remoteRepo) throws IOException { // fetch open prs Map<Integer, GHPullRequest> remotePulls = execute(() -> remoteRepo.getPullRequests(GHIssueState.OPEN)).stream() .collect(Collectors.toMap(GHPullRequest::getNumber, Function.identity())); // collect closed pull requests we knew of previously Stream<GHPullRequest> closed = new HashSet<>(localRepo.getPulls().keySet()).stream() .filter(pr -> !remotePulls.containsKey(pr)) .map(iof(remoteRepo::getPullRequest)); return Stream.concat(remotePulls.values().stream(), closed); }
/** * List up repositories that has some open pull requests. * * This used to be an efficient method that didn't involve traversing every repository, but now * it doesn't do any optimization. */ public List<GHRepository> getRepositoriesWithOpenPullRequests() throws IOException { List<GHRepository> r = new ArrayList<GHRepository>(); for (GHRepository repository : listRepositories(100)) { repository.wrap(root); List<GHPullRequest> pullRequests = repository.getPullRequests(GHIssueState.OPEN); if (pullRequests.size() > 0) { r.add(repository); } } return r; }
/** * List up repositories that has some open pull requests. * * This used to be an efficient method that didn't involve traversing every repository, but now * it doesn't do any optimization. */ public List<GHRepository> getRepositoriesWithOpenPullRequests() throws IOException { List<GHRepository> r = new ArrayList<GHRepository>(); for (GHRepository repository : listRepositories(100)) { repository.wrap(root); List<GHPullRequest> pullRequests = repository.getPullRequests(GHIssueState.OPEN); if (pullRequests.size() > 0) { r.add(repository); } } return r; }
/** * List up repositories that has some open pull requests. * * This used to be an efficient method that didn't involve traversing every repository, but now * it doesn't do any optimization. */ public List<GHRepository> getRepositoriesWithOpenPullRequests() throws IOException { List<GHRepository> r = new ArrayList<GHRepository>(); for (GHRepository repository : listRepositories()) { repository.wrap(root); List<GHPullRequest> pullRequests = repository.getPullRequests(GHIssueState.OPEN); if (pullRequests.size() > 0) { r.add(repository); } } return r; }
public static void validatePullRequestCreation(GHRepository repo, boolean created) throws Exception { GHRepository parentRepo = repo.getParent(); List<GHPullRequest> prs = parentRepo.getPullRequests(GHIssueState.OPEN); if (created) { assertEquals(prs.size(), 1, "There should only be one pull request."); for (GHPullRequest pr : prs) { // TODO: In sometimes two commits are generated; a blank one followed tag bump. Ideally we'd have one Assertions.assertThat(pr.listCommits().asList().size()).isGreaterThanOrEqualTo(1); } } else { assertEquals(prs.size(), 0, "There should be no pull requests."); } }
public static List<GHPullRequest> getOpenPullRequests(GHRepository ghRepository, String label) throws IOException { List<GHPullRequest> pullRequests = retryGithub(() -> ghRepository.getPullRequests(GHIssueState.OPEN)); List<GHPullRequest> answer = new ArrayList<>(); if (pullRequests != null) { for (GHPullRequest pullRequest : pullRequests) { if (GitHubHelpers.hasLabel(Issues.getLabels(pullRequest), label)) { answer.add(pullRequest); } } } return answer; }
public static List<GHPullRequest> getOpenPullRequests(GHRepository ghRepository, String label) throws IOException { List<GHPullRequest> pullRequests = retryGithub(() -> ghRepository.getPullRequests(GHIssueState.OPEN)); List<GHPullRequest> answer = new ArrayList<>(); if (pullRequests != null) { for (GHPullRequest pullRequest : pullRequests) { if (GitHubHelpers.hasLabel(Issues.getLabels(pullRequest), label)) { answer.add(pullRequest); } } } return answer; }
@Test(dependsOnMethods = "testStoreUpdate") public void testAsUser() throws Exception { GHRepository repo = github.getOrganization(ORG).getRepository(NAME); List<GHPullRequest> prs = repo.getPullRequests(GHIssueState.OPEN); Assert.assertTrue(prs.size() == 1); for (GHPullRequest pr : prs) { pr.merge("Automatic merge through itests."); pr.close(); } try (InputStream stream = repo.getFileContent("Dockerfile").read(); InputStreamReader streamR = new InputStreamReader(stream); BufferedReader reader = new BufferedReader(streamR)) { String line; while ((line = reader.readLine()) != null) { if (line.contains("FROM")) { Assert.assertTrue(line.contains(IMAGE)); Assert.assertTrue(line.endsWith(TAG)); } } } }
private GitHubRepository mapGhRepository(GHRepository gitHubRepository) throws IOException { String repositoryName = gitHubRepository.getName(); int stars = gitHubRepository.listStargazers().asList().size(); int openPullRequests = gitHubRepository.getPullRequests(GHIssueState.OPEN).size(); int pullRequests = openPullRequests + gitHubRepository.getPullRequests(GHIssueState.CLOSED).size(); int openIssues = gitHubRepository.getOpenIssueCount(); int branches = gitHubRepository.getBranches().size(); int collaborators = gitHubRepository.getCollaborators().size(); int forks = gitHubRepository.getForks(); int watchers = gitHubRepository.getWatchers(); return new GitHubRepository(repositoryName, stars, openPullRequests, pullRequests, openIssues, branches, collaborators, forks, watchers); }
private GHPullRequest getPullRequestWithPullReqIdentifier(GHRepository parent) throws IOException { List<GHPullRequest> pullRequests; GHUser myself; try { pullRequests = parent.getPullRequests(GHIssueState.OPEN); myself = gitHubUtil.getMyself(); } catch (IOException e) { log.warn("Error occurred while retrieving pull requests for {}", parent.getFullName()); return null; } for (GHPullRequest pullRequest : pullRequests) { GHUser user = pullRequest.getHead().getUser(); if (myself.equals(user) && pullRequest.getBody().equals(Constants.PULL_REQ_ID)) { return pullRequest; } } return null; } }
private GHPullRequest getPullRequestWithPullReqIdentifier(GHRepository parent) throws IOException { List<GHPullRequest> pullRequests; GHUser myself; try { pullRequests = parent.getPullRequests(GHIssueState.OPEN); myself = gitHubUtil.getMyself(); } catch (IOException e) { log.warn("Error occurred while retrieving pull requests for {}", parent.getFullName()); return null; } for (GHPullRequest pullRequest : pullRequests) { GHUser user = pullRequest.getHead().getUser(); if (myself.equals(user) && pullRequest.getBody().equals(Constants.PULL_REQ_ID)) { return pullRequest; } } return null; } }
openPulls = repo.getPullRequests(GHIssueState.OPEN); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Could not retrieve open pull requests.", ex);
/** * @return remote pull requests for future analysing. */ private static Set<GHPullRequest> pullRequestsToCheck(@Nullable Integer prNumber, @Nonnull GHRepository remoteRepo, @Nonnull GitHubPRRepository localRepo) throws IOException { if (prNumber != null) { return execute(() -> singleton(remoteRepo.getPullRequest(prNumber))); } else { List<GHPullRequest> remotePulls = execute(() -> remoteRepo.getPullRequests(GHIssueState.OPEN)); Set<Integer> remotePRNums = from(remotePulls).transform(extractPRNumber()).toSet(); return from(localRepo.getPulls().keySet()) // add PRs that was closed on remote .filter(not(in(remotePRNums))) .transform(fetchRemotePR(remoteRepo)) .filter(notNull()) .append(remotePulls) .toSet(); } }