Skip to content

Support preview Protected Branches API #934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

scriptonist
Copy link
Contributor

@scriptonist scriptonist commented Jun 22, 2018

This PR corresponds to #876

I've removed the protected branches preview media type from the corresponding functions which were required to complete this PR.Please review and suggest fixes if needed, Apologies for the late PR.

Fixes #876

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Jun 22, 2018
@@ -560,11 +560,13 @@ type RequiredStatusChecks struct {
// PullRequestReviewsEnforcement represents the pull request reviews enforcement of a protected branch.
type PullRequestReviewsEnforcement struct {
// Specifies which users and teams can dismiss pull request reviews.
Copy link
Collaborator

Choose a reason for hiding this comment

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

As written. the new omitempty tags aren't useful because the fields are not pointers and therefore can not be nil.

But looking back at https://github.com/google/go-github/pull/637/files , I'm not seeing why these were not originally made to be pointers with the omitempty tag. Maybe @shurcooL remembers? I read through the comments but it looks like I didn't bring up this point before and neither did anyone else.

Unless @shurcooL says otherwise, I'm thinking that these fields need to be turned into pointers and the omitempty tags should be added since these are return values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry I didn't get you. Should I make any changes or are we waiting for @shurcooL for a response?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's go ahead and change these fields to pointers and add omitempty since this struct is part of the return value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry for the confusion. It looks like you have already added omitempty to all the PullRequestReviewsEnforcement struct fields, which is what I was requesting.

I'm thinking that to make the omitempty tags effective, we should also make all the fields pointers.

So they would be:

DismissalRestrictions *DismissalRestrictions ...
DismissStaleReviews *bool ...
RequireCodeOwnerReviews *bool ...
...

Please let me know if that is not clear.

@jkosecki - maybe you can comment on what you think about these proposed changes since you authored #617?

Copy link
Contributor Author

@scriptonist scriptonist Jul 3, 2018

Choose a reason for hiding this comment

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

This may be a noob question but why are we using pointers for types like int and bool? @gmlewis

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is an excellent question, @scriptonist, and there have been several very good discussions about it. In a nutshell, it is so that we can tell if the server populated the field that it sent back to us which is especially important for variables like bool where you want to know if you are really getting back a false or if the server didn't send a value at all.

It is actually more important on the request side than the response side, really... which is why they may not be needed at all in this situation. I think I'm contradicting what I said earlier, unfortunately, and apologize. I said "since this struct is part of the return value". That is not good enough reason to make this change, really...

So I'm thinking now, let's hold off on my most recent request to make these all pointers.
Especially if the docs seem to indicate that these fields will always be sent in the reply.

Hopefully @jkosecki or @shurcooL can provide a code review and then we can get this merged when they are also happy with the changes. As this stands, I'm going to give this my LGTM.

Thanks again, @scriptonist, for bearing with me.

Here is a search of some of the previous great discussions about using pointers in this repo:
https://github.com/google/go-github/issues?utf8=%E2%9C%93&q=is%3Aissue+pointers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @gmlewis for the detailed explanation. I was curious to know why things are like this. This was a perfect answer to that. I really appreciate your willingness to assist.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

LGTM.
Awaiting second LGTM (hopefully from @shurcooL or
@jkosecki) before merging.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Jul 3, 2018
@gmlewis gmlewis requested a review from juliaferraioli August 10, 2018 15:05
Copy link
Contributor

@juliaferraioli juliaferraioli left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @scriptonist!

@gmlewis
Copy link
Collaborator

gmlewis commented Aug 10, 2018

Thank you, @juliaferraioli!
When attempting to resolve conflicts, I see that I've allowed similar changes to be made in other PRs.
I'm going to have to create a new PR for this one to pull in its changes and manually resolve conflicts.

@juliaferraioli
Copy link
Contributor

@gmlewis I was worried that would be the case. Thanks :-\

@gmlewis
Copy link
Collaborator

gmlewis commented Aug 10, 2018

Actually, now that I'm looking at the final results of the merge, all the important things have been addressed, and the extra omitemptys are really not desirable anyway because these fields can't be omitted as they are not pointers.

See #974 for details.

Closing.

@gmlewis gmlewis closed this Aug 10, 2018
@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support preview Protected Branches API
4 participants