Skip to content

Add support for Branch required_linear_history/allow_force_pushes/allow_deletions#1723

Closed
teejae wants to merge 2 commits intoPyGithub:masterfrom
teejae:add-branch-protection-options
Closed

Add support for Branch required_linear_history/allow_force_pushes/allow_deletions#1723
teejae wants to merge 2 commits intoPyGithub:masterfrom
teejae:add-branch-protection-options

Conversation

@teejae
Copy link

@teejae teejae commented Oct 19, 2020

Add new BranchProtection options listed here: https://developer.github.com/v3/repos/branches/

  • required_linear_history
  • allow_force_pushes
  • allow_deletions

Testing:
FYI, I could not figure out how to get the tests to run correctly

@s-t-e-v-e-n-k
Copy link
Collaborator

I'm a little confused by this -- you add the three arguments to Branch.edit, but add the methods to BranchProtection? BranchProtection is just for protection attrributes of Branch, I daresay those belong on Branch.

@s-t-e-v-e-n-k
Copy link
Collaborator

I understand what is going on better now -- those attributes only need to be added to BranchProtection.py (and BranchProtection.pyi).

@teejae
Copy link
Author

teejae commented Nov 2, 2020

@s-t-e-v-e-n-k Thanks for the review! I added to BranchProtection.py for reading values, but if I don't also add to the Branch.py, how do I edit the protection values? I believe that's the right place. Can you confirm/deny?

Copy link
Collaborator

@s-t-e-v-e-n-k s-t-e-v-e-n-k left a comment

Choose a reason for hiding this comment

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

Indeed, that is looking better. The replay data needs to be fixed to support the new attributes, since you've changed what is sent, which is why the tests fail, as well as adding a test case that changes them. You'll also need to edit the Branch.pyi and BranchProtection.pyi files to add the typing hints.

@teejae
Copy link
Author

teejae commented Nov 3, 2020

@s-t-e-v-e-n-k thanks for the confirmation. i hadn't yet changed any code relative to the first commit.

i admit that i couldn't figure out how to generate replay data.

@s-t-e-v-e-n-k
Copy link
Collaborator

https://github.com/PyGithub/PyGithub/blob/master/CONTRIBUTING.md has an Automated tests section on how to do so.

@teejae
Copy link
Author

teejae commented Dec 2, 2020

FYI, with the github v4 graphql API now supporting these options, I no longer need this v3 API option. I had not been able to figure out how to fix the tests, even after reading the CONTRIBUTING.md file.

Closing this PR for now.

https://developer.github.com/v4/changelog/2020-11-13-schema-changes/

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