public PullRequest findOpenPullRequest(String upstreamRepositoryName, String versionBranchRegex, GitHubApi gitHubApi) throws IOException { String response = gitHubApi.get("/repos/" + upstreamRepositoryName + "/pulls?state=open"); JsonArray pullRequests = Jsoner.deserialize(response, new JsonArray()); for (Object pullRequest : pullRequests) { PullRequest openPullRequest = PullRequestUtils.toPullRequest((JsonObject) pullRequest); if (openPullRequest != null && openPullRequest.getRef().matches(versionBranchRegex)) { LOG.lifecycle(" Found an open pull request with version upgrade on branch {}", openPullRequest.getRef()); return openPullRequest; } } LOG.lifecycle(" New pull request will be opened because we didn't find an existing PR to reuse."); return null; } }
public PullRequest findOpenPullRequest(String upstreamRepositoryName, String versionBranchRegex, GitHubApi gitHubApi) throws IOException { String response = gitHubApi.get("/repos/" + upstreamRepositoryName + "/pulls?state=open"); JsonArray pullRequests = Jsoner.deserialize(response, new JsonArray()); for (Object pullRequest : pullRequests) { PullRequest openPullRequest = PullRequestUtils.toPullRequest((JsonObject) pullRequest); if (openPullRequest != null && openPullRequest.getRef().matches(versionBranchRegex)) { LOG.lifecycle(" Found an open pull request with version upgrade on branch {}", openPullRequest.getRef()); return openPullRequest; } } LOG.lifecycle(" New pull request will be opened because we didn't find an existing PR to reuse."); return null; } }
public void addPullRequestReviewer(PullRequestRef pr, long pullRequestVersion, List<StashUser> reviewers) { String request = MessageFormat.format(API_ONE_PR, baseUrl, pr.project(), pr.repository(), pr.pullRequestId()); JsonObject json = new JsonObject(); JsonArray jsonReviewers = new JsonArray(); for (StashUser reviewer : reviewers) { JsonObject reviewerName = new JsonObject(); reviewerName.put("name", reviewer.getName()); JsonObject user = new JsonObject(); user.put("user", reviewerName); jsonReviewers.add(user); } json.put("reviewers", jsonReviewers); json.put("id", pr.pullRequestId()); json.put("version", pullRequestVersion); put(request, json, MessageFormat.format(PULL_REQUEST_PUT_ERROR_MESSAGE, pr.repository(), pr.pullRequestId())); }