Add support for PR reviews preview#352
Conversation
| /* | ||
| * The MIT License | ||
| * | ||
| * Copyright (c) 2010, Kohsuke Kawaguchi |
|
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
oleg-nenashev
left a comment
There was a problem hiding this comment.
The code mostly looks good to me 🐝 , there are minor improvement proposals.
@reviewbybees done
| } | ||
|
|
||
| /** | ||
| * Retrieves all the reviews associated to this pull request. |
| * Updates the comment. | ||
| */ | ||
| @Preview | ||
| @Deprecated |
There was a problem hiding this comment.
Maybe it worth adding dependency on accmod and adding @Restricted annotations instead
| public PagedIterable<GHPullRequestReview> listReviews() { | ||
| return new PagedIterable<GHPullRequestReview>() { | ||
| public PagedIterator<GHPullRequestReview> _iterator(int pageSize) { | ||
| return new PagedIterator<GHPullRequestReview>(root.retrieve() |
There was a problem hiding this comment.
What about adding an entry in Previews class?
|
Hi, I'm interested in this PR, actually I've even enchanced this with support of new Events (Status and PullRequestReview). But to submit my PR, I'd need this merged first. |
|
I think only @kohsuke can do that. |
|
Fixes #305 |
|
I have accidentally created a pull request for the same purpose (#366) and I must confess that I'm very surprised that they are similar in so many ways. Regardless of that, since this PR has been created before and has already been reviewed by a CloudBees employee, I will close mine in favour or this one. I will do my review on this one too since we both spent a significant time working on this matter and I would love to see this merged in the short-term as some of the automation process I created at work would really benefit of it. @kohsuke when you have a spare time, please merge it ;) |
PauloMigAlmeida
left a comment
There was a problem hiding this comment.
I don't think any of the points I mentioned is a blocker to get this merged as I have pointed out only minor changes.
| } | ||
| } | ||
|
|
||
| private static class DraftReviewComment { |
There was a problem hiding this comment.
It's just my 2 cents opinion but why don't you make this public and add the GH prefix on it too to make it standard with the majority of the other classes in the project.
| } | ||
| return new Requester(root).method("POST") | ||
| .with("body", body) | ||
| //.with("event", event.name()) |
There was a problem hiding this comment.
Correct me if I'm wrong but if you aren't sending the event, then all of the reviews will be set to Pending state, right? If that's the case, why you have the event parameter in the first place?
I think we should let send it as it was specified in the method signature (2 cents opinion again)
| .with("body", body) | ||
| //.with("event", event.name()) | ||
| ._with("comments", draftComments) | ||
| .withPreview("application/vnd.github.black-cat-preview+json") |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
| return createReview(body, event, Arrays.asList(comments)); | ||
| } | ||
|
|
||
| @Preview |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
| } | ||
|
|
||
| @Preview | ||
| @Deprecated |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
| * Dismisses this review. | ||
| */ | ||
| @Preview | ||
| @Deprecated |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
| public void dismiss(String message) throws IOException { | ||
| new Requester(owner.root).method("PUT") | ||
| .with("message", message) | ||
| .withPreview("application/vnd.github.black-cat-preview+json") |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
| public PagedIterator<GHPullRequestReviewComment> _iterator(int pageSize) { | ||
| return new PagedIterator<GHPullRequestReviewComment>( | ||
| owner.root.retrieve() | ||
| .withPreview("application/vnd.github.black-cat-preview+json") |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
| /** | ||
| * Obtains all the review comments associated with this pull request review. | ||
| */ | ||
| @Preview |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
| * Obtains all the review comments associated with this pull request review. | ||
| */ | ||
| @Preview | ||
| @Deprecated |
There was a problem hiding this comment.
This is no long a preview method, so you can remove this line
@porcelli Now that this is merged and released would you be able to issue your PR to add event support for PR reviews? |
|
@mattnelson the new events (Status and PullRequestReview) that @porcelli mentioned were already merged in this PR: https://github.com/kohsuke/github-api/pull/363/files |
|
@PauloMigAlmeida thanks, I missed that. I was specifically looking for the data binding in |
|
Hi @mattnelson If what you want it to implement a hook based on the public class GitConfigRepositoryOperation extends AbstractGitHubOperation<Void> {
private GHRepository repository;
private final static String webhookUrl;
static{
webhookUrl = KMSEnvironmentalVariableDecryptService.getInstance().decryptKey("GitWebhookUrl");
}
public GitConfigRepositoryOperation(GHRepository repository) throws IOException {
super(repository.getFullName());
this.repository = repository;
}
@Override
public Void performOperation() throws Exception {
// Configure Webhook
Map<String, String> configMap = new HashMap<>(2);
configMap.put("url", webhookUrl);
configMap.put("content_type", "json");
this.repository.createHook("web",
configMap,
Arrays.asList(
GHEvent.PULL_REQUEST,
GHEvent.PULL_REQUEST_REVIEW,
GHEvent.PULL_REQUEST_REVIEW_COMMENT,
GHEvent.PUSH,
GHEvent.CREATE
), true);
return null;
}Hope that it helps. |
@reviewbybees