Skip to content

Add Preview Support for Team Review Requests - #682

Merged
dmitshur merged 4 commits into
google:masterfrom
RaviTezu:team-review-req-preview
Aug 9, 2017
Merged

dmitshur merged 4 commits into
google:masterfrom
RaviTezu:team-review-req-preview

Conversation

@RaviTezu

@RaviTezu RaviTezu commented Aug 6, 2017

Copy link
Copy Markdown
Contributor

Adding preview support for team review requests.
Fixes #678

@RaviTezu

RaviTezu commented Aug 6, 2017

Copy link
Copy Markdown
Contributor Author

As @gmlewis mentioned in the issue, this involves a breaking change and we may need to bump the package version number.
@shurcooL

@RaviTezu

RaviTezu commented Aug 6, 2017

Copy link
Copy Markdown
Contributor Author

@gmlewis @shurcooL
I see github.go has a const libraryVersion = "8". Shall I change this to libraryVersion = "9" ?

@dmitshur

dmitshur commented Aug 7, 2017

Copy link
Copy Markdown
Member

I see github.go has a const libraryVersion = "8". Shall I change this to libraryVersion = "9" ?

Yes, please do. That'll help us communicate that there are breaking API changes being done (as a result of GitHub preview API changing).

Comment thread github/pulls_reviewers.go Outdated
@@ -13,18 +13,22 @@ import (
// RequestReviewers creates a review request for the provided GitHub users for the specified pull request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the provided GitHub users

This was true before the change, but we'll need to update docs now to describe the new API.

@dmitshur
dmitshur requested a review from gmlewis August 7, 2017 04:42
Comment thread github/pulls_reviewers.go Outdated
//
// GitHub API docs: https://developer.github.com/v3/pulls/review_requests/#create-a-review-request
func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, logins []string) (*PullRequest, *Response, error) {
func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, logins []string, teams []string) (*PullRequest, *Response, error) {

@dmitshur dmitshur Aug 7, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis, what do you think about this API decision?

An alternative to consider (that I can think of) is to create a ReviewersRequest struct which contains the two string slices, and have the caller pass that in.

I'm pretty torn between the two, it seems they tradeoffs are pretty much equivalent and I'm not strongly in favor of either of them.

@dmitshur

dmitshur commented Aug 7, 2017

Copy link
Copy Markdown
Member

@RaviTezu Thanks for your work on this PR! It's looking very solid so far. I've only briefly looked at it. First, I want to think about the API and decide which direction we'll want to go. Afterwards, I can review the implementation details more closely.

@gmlewis

gmlewis commented Aug 7, 2017

Copy link
Copy Markdown
Collaborator

LGTM
This seems like a good way to go (to me) for the API.
If @shurcooL comes up with a better alternative, I'm happy to discuss the tradeoffs.

@RaviTezu

RaviTezu commented Aug 9, 2017

Copy link
Copy Markdown
Contributor Author

@shurcooL Any thoughts on how to move forward with this API?

@dmitshur dmitshur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've thought about this for a while, and it's not easy to do this, but I will make the suggest to consider changing the API after all.

This is my alternative suggestion:

// ReviewersRequest specifies users and teams for a pull request review request.
type ReviewersRequest struct {
	Reviewers     []string `json:"reviewers,omitempty"`
	TeamReviewers []string `json:"team_reviewers,omitempty"`
}

func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*PullRequest, *Response, error) { ... }

func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*Response, error) { ... }

There are 2 main reasons for this suggestion:

  1. I think it might lead to more readable usage code. Consider:

    pull, _, err := c.PullRequests.RequestReviewers(ctx, "o", "r", 1, []string{"a", "b"}, nil)
    pull, _, err := c.PullRequests.RequestReviewers(ctx, "o", "r", 1, nil, []string{"c", "d"})
    pull, _, err := c.PullRequests.RequestReviewers(ctx, "o", "r", 1, []string{"a", "b"}, []string{"c", "d"})

    With code like that, it's harder to see what the parameters are. Compare with:

    pull, _, err := c.PullRequests.RequestReviewers(ctx, "o", "r", 1, github.ReviewersRequest{
    	Reviewers:     []string{"a", "b"},
    	TeamReviewers: nil,
    })
    pull, _, err := c.PullRequests.RequestReviewers(ctx, "o", "r", 1, github.ReviewersRequest{
    	Reviewers:     nil,
    	TeamReviewers: []string{"c", "d"},
    })
    pull, _, err := c.PullRequests.RequestReviewers(ctx, "o", "r", 1, github.ReviewersRequest{
    	Reviewers:     []string{"a", "b"},
    	TeamReviewers: []string{"c", "d"},
    })
  2. I'm worried there's a small chance of additional types of reviewers that the GitHub API might get added in the future. If so, we would have to break the API yet again, and make it even more unreadable by having 3 slices in a row.

I don't think the difference between the two options is significant at this time. That makes this decision harder. But, given the options and information we have now, since we're making a breaking API change, I have a slight preference for this proposed API in the long run.

What do you think?

Comment thread github/pulls_reviewers.go
if err != nil {
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with other places, add a blank line above this line.

@gmlewis

gmlewis commented Aug 9, 2017

Copy link
Copy Markdown
Collaborator

@shurcooL's suggestions SGTM.

@RaviTezu

RaviTezu commented Aug 9, 2017 •

Copy link
Copy Markdown
Contributor Author

@shurcooL I do agree with you.
It increases the readability and the recent commit has the suggested API changes.
Take a look. @gmlewis

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the changes. LGTM.
Thank you, @RaviTezu and @shurcooL!

@dmitshur dmitshur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for doing this!

One minor comment, afterwards we can merge.

Comment thread github/pulls_reviewers.go
type ReviewersRequest struct {
Reviewers []string `json:"reviewers,omitempty"`
TeamReviewers []string `json:"team_reviewers,omitempty"`
}

@dmitshur dmitshur Aug 9, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, swap the order of these two structs, so ReviewersRequest, the input, is on top, and Reviewers, the output, is below it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shurcooL Done.

@dmitshur
dmitshur merged commit 057228c into google:master Aug 9, 2017
@RaviTezu
RaviTezu deleted the team-review-req-preview branch August 10, 2017 04:53
nbareil pushed a commit to nbareil/go-github that referenced this pull request May 1, 2018
This is a breaking API change to support an upcoming github.com REST API
breaking change. It adds support to add, delete, and fetch team review requests.

GitHub Announcement: https://developer.github.com/changes/2017-07-26-team-review-request-thor-preview/

Increase libraryVersion by one.

Fixes google#678.
jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
This is a breaking API change to support an upcoming github.com REST API
breaking change. It adds support to add, delete, and fetch team review requests.

GitHub Announcement: https://developer.github.com/changes/2017-07-26-team-review-request-thor-preview/

Increase libraryVersion by one.

Fixes google#678.
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.

3 participants