github-api icon indicating copy to clipboard operation
github-api copied to clipboard

getIssue() from GHPullRequest object

Open KostyaSha opened this issue 10 years ago • 6 comments

Could such method be added into PR object? Issue and PR content differs and it very inconvenient to do a call through parent like pr.getRepository().getIssue(pr.getNumber())

KostyaSha avatar Apr 14 '15 00:04 KostyaSha

GHPullRequest extends from GHIssue, so the design here is to call GHPullRequest.fetchIssue() at the right point to ensure methods defined on GHIssue return correct info when used on GHPullRequest instance, such as getLabels() do.

For what methods are you seeing differing return values?

kohsuke avatar Apr 20 '15 00:04 kohsuke

@kohsuke assumption that Issue and PR has the same data is wrong. They track different instances of data. Example is date time of changes: https://github.com/KostyaSha/github-pullrequest-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger.java#L370-L371

KostyaSha avatar Apr 20 '15 00:04 KostyaSha

And https://github.com/kohsuke/github-api/blob/master/src/main/java/org/kohsuke/github/GHPullRequest.java#L111 is Deprecated

KostyaSha avatar Apr 20 '15 01:04 KostyaSha

More details about updated_at. If you change label or comment -> it issue change. If you change commits -> PR change. It looks like in GH internal structure it two different objects (and PR is not extended Issue). I'm afraid problems using api library if GH adds more fields, so i prefer using right objects for getting data. And getting Issue from PR seems logical, because it one-direction logical link.

KostyaSha avatar Apr 20 '15 01:04 KostyaSha

, so the design here is to call GHPullRequest.fetchIssue() at the right point

Also this method is private, having fetchissue and populate methods public should help with getting almost atomic state of remote PR+issue.

KostyaSha avatar Jun 01 '15 19:06 KostyaSha

It would be nice if there was an easier way to get a PR from an issue too.

drewish avatar Apr 30 '17 05:04 drewish