Skip to content

Allow pullRequest.getHead().getRepository().getCommit(headSha1) to work#129

Merged
mocleiri merged 1 commit into
hub4j:masterfrom
mocleiri:fix-pull-request-remote-repo-get-commit
Sep 26, 2014
Merged

Allow pullRequest.getHead().getRepository().getCommit(headSha1) to work#129
mocleiri merged 1 commit into
hub4j:masterfrom
mocleiri:fix-pull-request-remote-repo-get-commit

Conversation

@mocleiri
Copy link
Copy Markdown
Collaborator

The wrong .wrap method was used for pull requests initialized by state
(GHRepository.getPullReqests).

The wrong wrap call was introduced in 9fd34ae

This commit sets it back to the .wrapUp method which makes sure the pull request
substructure has the repo object set properly.

Without this change a NullPointerException is thrown on the last line of this
code because the repo object inside of the remoteRepository object is null:

GHRepository repo = github.getRepository(targetRepository);

List openPullRequests = repo.getPullRequests(GHIssueState.OPEN);

for (GHPullRequest pullRequest : openPullRequests) {

GHCommitPointer head = pullRequest.getHead();

GHRepository remoteRepository = head.getRepository();

String commitId = head.getSha();

GHCommit headCommit = remoteRepository.getCommit(commitId);

The wrong .wrap method was used for pull requests initialized by state
(GHRepository.getPullReqests).

The wrong wrap call was introduced in 9fd34ae

This commit sets it back to the .wrapUp method which makes sure the pull request
substructure has the repo object set properly.

Without this change a NullPointerException is thrown on the last line of this
code because the repo object inside of the remoteRepository object is null:

GHRepository repo = github.getRepository(targetRepository);

List<GHPullRequest> openPullRequests = repo.getPullRequests(GHIssueState.OPEN);

for (GHPullRequest pullRequest : openPullRequests) {

    GHCommitPointer head = pullRequest.getHead();

	GHRepository remoteRepository = head.getRepository();

	String commitId = head.getSha();

	GHCommit headCommit = remoteRepository.getCommit(commitId);
@buildhive
Copy link
Copy Markdown

Kohsuke Kawaguchi » github-api #234 SUCCESS
This pull request looks good
(what's this?)

mocleiri added a commit that referenced this pull request Sep 26, 2014
…t-commit

Allow pullRequest.getHead().getRepository().getCommit(headSha1) to work
@mocleiri mocleiri merged commit 7b46ef1 into hub4j:master Sep 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants