@Override public GHPullRequest apply(Integer input) { try { return ghRepository.getPullRequest(input); } catch (IOException e) { LOGGER.error("Can't fetch pr by num {}", input, e); return null; } } }
/** * If this thread is about a pull request, return that pull request. * * @return null if this thread is not about a pull request. */ public GHPullRequest getBoundPullRequest() throws IOException { if (!"PullRequest".equals(subject.type)) return null; return repository.getPullRequest( Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1))); }
/** * If this thread is about a pull request, return that pull request. * * @return null if this thread is not about a pull request. */ public GHPullRequest getBoundPullRequest() throws IOException { if (!"PullRequest".equals(subject.type)) return null; return repository.getPullRequest( Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1))); }
/** * If this thread is about a pull request, return that pull request. * * @return null if this thread is not about a pull request. */ public GHPullRequest getBoundPullRequest() throws IOException { if (!"PullRequest".equals(subject.type)) return null; return repository.getPullRequest( Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1))); }
public String getPullRequestBody(int requestNumber) throws IOException { return ghRepo.getPullRequest(requestNumber).getBody(); }
public GHPullRequest getActualPullRequest(int id) throws IOException { return getGitHubRepo().getPullRequest(id); }
public String getPullRequestTitle(int requestNumber) throws IOException { return ghRepo.getPullRequest(requestNumber).getTitle(); }
public void closePullRequest(int id) { try { GHRepository repo = getGitHubRepo(); GHPullRequest pr = repo.getPullRequest(id); pr.close(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Could not close the pull request #" + id + ": '", ex); } }
public String getPullRequestUserName(int requestNumber) throws IOException { return ghRepo.getPullRequest(requestNumber).getUser().getLogin(); } }
public String getPullRequestHeadBranchName(int requestNumber) throws IOException { return ghRepo.getPullRequest(requestNumber).getHead().getRef(); }
public String getPullRequestBaseBranchName(int requestNumber) throws IOException { return ghRepo.getPullRequest(requestNumber).getBase().getRef(); }
public static GHIssue getGhPullRequest(final Run<?, ?> run) throws IOException { return getGhRepositoryFromPRTrigger(run).getPullRequest(getPRNumberFromPRCause(run)); }
@Override public String fetchHeadSha(GHRepository remoteRepo) throws IOException { GHPullRequest pullRequest = remoteRepo.getPullRequest(prNumber); if (pullRequest == null) { throw new IOException("No PR " + prNumber + " in " + remoteRepo.getFullName()); } return pullRequest.getHead().getSha(); }
public void addComment(int id, String comment, Run<?, ?> build, TaskListener listener) { if (comment.trim().isEmpty()) { return; } if (build != null && listener != null) { try { comment = build.getEnvironment(listener).expand(comment); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error", e); } } try { GHRepository repo = getGitHubRepo(); GHPullRequest pr = repo.getPullRequest(id); pr.comment(comment); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Could not add comment to pull request #" + id + ": '" + comment + "'", ex); } }
private GhprbPullRequest getPullRequest(GHPullRequest ghpr, Integer number) throws IOException { if (number == null) { number = ghpr.getNumber(); } synchronized (this) { GhprbPullRequest pr = pullRequests.get(number); if (pr == null) { if (ghpr == null) { GHRepository repo = getGitHubRepo(); ghpr = repo.getPullRequest(number); } pr = new GhprbPullRequest(ghpr, trigger.getHelper(), this); pullRequests.put(number, pr); } return pr; } }
public static boolean isMergeable(GHPullRequest pullRequest) throws IOException { boolean canMerge = false; Boolean mergeable = pullRequest.getMergeable(); GHPullRequest single = null; if (mergeable == null) { single = pullRequest.getRepository().getPullRequest(pullRequest.getNumber()); mergeable = single.getMergeable(); } if (mergeable == null) { LOG.warn("Mergeable flag is still null on pull request " + pullRequest.getHtmlUrl() + " assuming its still mergable. Probably a caching issue and this flag may appear again later"); return true; } if (mergeable != null && mergeable.booleanValue()) { canMerge = true; } return canMerge; }
public static boolean isMergeable(GHPullRequest pullRequest) throws IOException { boolean canMerge = false; Boolean mergeable = pullRequest.getMergeable(); GHPullRequest single = null; if (mergeable == null) { single = pullRequest.getRepository().getPullRequest(pullRequest.getNumber()); mergeable = single.getMergeable(); } if (mergeable == null) { LOG.warn("Mergeable flag is still null on pull request " + pullRequest.getHtmlUrl() + " assuming its still mergable. Probably a caching issue and this flag may appear again later"); return true; } if (mergeable != null && mergeable.booleanValue()) { canMerge = true; } return canMerge; }
private GHPullRequest pullRequestFrom(GitConfig gitConfig, int currentPullRequestID) throws IOException { return loginWith(gitConfig) .getRepository(GHUtils.parseGithubUrl(gitConfig.getEffectiveUrl())) .getPullRequest(currentPullRequestID); }
private String getParentSha(final GHCommit commit, final GitBranch gitBranch) throws IOException { final String parentSha; if (gitBranch.isPullRequest()) { final GHPullRequest pullRequest = this.githubRepositoryService.getGithubRepository().getPullRequest(gitBranch.pullRequestNumber()); parentSha = pullRequest.getBase().getSha(); } else { parentSha = (commit.getParentSHA1s() != null && commit.getParentSHA1s().size() > 0) ? commit.getParentSHA1s().get(0) : null; } return parentSha; }
public org.kohsuke.github.GHCommit getHeadCommitForBranch(final String branch) throws IOException { String sha; final GitBranch gitBranch = new GitBranch(branch); if (gitBranch.isPullRequest()) { try { sha = getGithubRepository().getPullRequest(gitBranch.pullRequestNumber()).getHead().getSha(); } catch (final IOException e) { throw new RuntimeException(e); } } else { try { final GHRef ref = getRef("heads/" + gitBranch); sha = ref.getObject().getSha(); } catch (final IOException e) { sha = gitBranch.toString(); } } return getGithubRepository().getCommit(sha); }