Pygithub: Add support for advanced branch protection APIs

Created on 30 Jun 2017  ·  15Comments  ·  Source: PyGithub/PyGithub

It seems like the following APIs exist in github v3 (as beta?) but are not yet reflected in this library.

It'd be great to have full support of this API (especially since it allows controlling PR reviews and how many are needed and by who).

feature request high priority

Most helpful comment

This is in fact a large mess. Repository.protect_branch() calls into an endpoint that has probably been removed, since GitHub blogged that it would be when Branch Protection graduated. I've been wondering why the API docs and the code are completely at odds with each other.

I'm going to add a new method Repository.edit_branch_protection() to call the new endpoint with the new data structures, and I'm tempted to remove Repository.protect_branch() at the same time for being broken.

All 15 comments

@harlowja I did a little bit of this in https://github.com/a13m/PyGithub/commit/3af108372a5179e16fc093b78568c8e45a3a91ca

It was enough for me to at least audit our branch protections. YMMV.

Ya, it'd be supernice to have something like that merged in (and released); this library seems to lag behind the actual API and/or capabilities, which makes me a little sad :-/

Especially would like this since I've been trying to ensure all my github configuration for my group is in a yaml format, and not hidden away in the github UI, and then having a program that parses said yaml format and adjusts various github repositories. This creates continuity (and sanity) across my groups repositories and having the ability to programmatically adjust the reviewer protections would logically be something a team would want to do (so that the reviewer list can be controlled & managed via a similar yaml format).

Nice work @a13m!
Meanwhile: https://developer.github.com/changes/2017-09-06-protected-branches-preview-end/.

Looks like we're stuck until someone musters the energy to tackle this.

you are now required to pass the required_pull_request_reviews object when calling the update branch protection endpoint. Passing this object was optional during the preview period.

I would love to see this too. PR please ❤️

This is in fact a large mess. Repository.protect_branch() calls into an endpoint that has probably been removed, since GitHub blogged that it would be when Branch Protection graduated. I've been wondering why the API docs and the code are completely at odds with each other.

I'm going to add a new method Repository.edit_branch_protection() to call the new endpoint with the new data structures, and I'm tempted to remove Repository.protect_branch() at the same time for being broken.

Hi folks, My patch is incomplete as yet but I thought it would be nice to have early feedback ^

I've also been working on this, approaching it in a different way -- by adding the methods to Branch, and dropping Repository.protect_branch()

@s-t-e-v-e-n-k ah I see that now. Hmm don't want to duplicate work. My intention was to keep the library api the same. How do you want to go about it?

@JPWKU I'm sorry, I should have communicated more clearly that I was actively working on this. The Repository.protect_branch() method did match the GitHub API, until they removed it when the new branch protection API graduated.

My current patch implements the branch protection API as GitHub shows on https://developer.github.com/v3/repos/branches/, as a consequence, it is rather large. I have 3 or so test cases to finish writing before I push this up.

@s-t-e-v-e-n-k no worries, since you've already got work in this area I'll close my PR and comment/help out on yours.

@s-t-e-v-e-n-k Do you plan to merge this soon? I'm in need of this functionality.

@prburgu It isn't up to me when it merges. @JPWKU when do you have some time to continue reviewing the attached PR?

@prburgu @s-t-e-v-e-n-k I'm gonna try to carve out time today or this evening to finish the review.

Any update on this?

Was this page helpful?
0 / 5 - 0 ratings