public String getAuthorRepoGitUrl() { GHCommitPointer prHead = pr.getHead(); String authorRepoGitUrl = ""; if (prHead != null && prHead.getRepository() != null) { authorRepoGitUrl = prHead.getRepository().gitHttpTransportUrl(); } return authorRepoGitUrl; }
/** * Does this repository match the repository referenced in the given {@link GHCommitPointer}? */ public boolean matches(GHCommitPointer commit) { final GHUser user; try { user = commit.getUser(); } catch (IOException ex) { LOGGER.debug("Failed to extract user from commit " + commit, ex); return false; } return userName.equals(user.getLogin()) && repositoryName.equals(commit.getRepository().getName()) && host.equals(commit.getRepository().getHtmlUrl().getHost()); }
/** * Obtains the commit that this pointer is referring to. */ public GHCommit getCommit() throws IOException { return getRepository().getCommit(getSha()); }
/** * Obtains the commit that this pointer is referring to. */ public GHCommit getCommit() throws IOException { return getRepository().getCommit(getSha()); }
/** * Obtains the commit that this pointer is referring to. */ public GHCommit getCommit() throws IOException { return getRepository().getCommit(getSha()); }
/** * {@inheritDoc} */ @Override public boolean isExcluded(@NonNull SCMSourceRequest request, @NonNull SCMHead head) { if (head instanceof BranchSCMHead && request instanceof GitHubSCMSourceRequest) { for (GHPullRequest p : ((GitHubSCMSourceRequest) request).getPullRequests()) { GHRepository headRepo = p.getHead().getRepository(); if (headRepo != null // head repo can be null if the PR is from a repo that has been deleted && p.getBase().getRepository().getFullName().equalsIgnoreCase(headRepo.getFullName()) && p.getHead().getRef().equals(head.getName())) { return true; } } } return false; } }
/** * {@inheritDoc} */ @Override public boolean isExcluded(@NonNull SCMSourceRequest request, @NonNull SCMHead head) { if (head instanceof BranchSCMHead && request instanceof GitHubSCMSourceRequest) { for (GHPullRequest p : ((GitHubSCMSourceRequest) request).getPullRequests()) { GHRepository headRepo = p.getHead().getRepository(); if (headRepo != null // head repo can be null if the PR is from a repo that has been deleted && p.getBase().getRepository().getFullName().equalsIgnoreCase(headRepo.getFullName()) && p.getHead().getRef().equals(head.getName())) { return false; } } return true; } return false; } }
PullRequest prInformation = new PullRequest(); GHRepository headRepo = pullRequest.getHead().getRepository();
private Commit createCommitForMetrics(PullRequest prInformation, boolean base) { Commit commit = new Commit(); GHCommitPointer ghCommitPointer; GHCommit ghCommit; if (base) { ghCommitPointer = prInformation.getBaseRef(); } else { ghCommitPointer = prInformation.getHeadRef(); } try { ghCommit = ghCommitPointer.getCommit(); String branchLabel = ghCommitPointer.getLabel(); String branchName = branchLabel.substring(branchLabel.indexOf(":") + 1, branchLabel.length()); commit.setRepoName(ghCommitPointer.getRepository().getFullName()); commit.setBranchName(branchName); commit.setSha(ghCommit.getSHA1()); commit.setUrl(ghCommit.getHtmlUrl().toString()); commit.setDate(ghCommit.getCommitDate()); return commit; } catch (IOException e) { this.addStepError("Exception while writing properties related to commits.", e); } return null; }
int n = 0; for (GHPullRequest pr: ghRepository.queryPullRequests().state(GHIssueState.OPEN).list()) { GHRepository repository = pr.getHead().getRepository();
PullRequestSCMHead(GHPullRequest pr, String name, boolean merge) { super(name); // the merge flag is encoded into the name, so safe to store here this.merge = merge; this.number = pr.getNumber(); this.target = new BranchSCMHead(pr.getBase().getRef()); // the source stuff is immutable for a pull request on github, so safe to store here GHRepository repository = pr.getHead().getRepository(); // may be null for deleted forks JENKINS-41246 this.sourceOwner = repository == null ? null : repository.getOwnerName(); this.sourceRepo = repository == null ? null : repository.getName(); this.sourceBranch = pr.getHead().getRef(); this.origin = pr.getRepository().getOwnerName().equalsIgnoreCase(sourceOwner) ? SCMHeadOrigin.DEFAULT : new SCMHeadOrigin.Fork(this.sourceOwner); }