Updating branch protection details is very cumbersome
I have a project where I have various branch protections enabled like linear history, required status checks, and so on and those restrictions should also be valid for administrators usually to not have a broken state on master.
But when creating a release, I actually want to push one merge commit to master and also without having the status checks run before as this would need manual intervention.
So I thought I simply make a Gradle task that removes the "also for administrators" flag before the push and another task that again enables that flag that is run after the task that pushes to master.
The problem is, that this lib does not allow to change only one detail, but you always have to supply the full set of protection rules. When I just did ....enableProtection().includeAdmins(false).enable(), all other properties were unset.
But I also don't want to maintain the restrictions in the code.
And taking the protections from the current protection object, setting them on the builder is extremely cumbersome and boiler-platey and also if some attributes get added, suddenly the logic will be wrong as it will not be copied over along except if you use reflection for this, which also would not work anyway due to inconsistencies in naming (e. g. requiredChecks vs. contexts).
It would be nice if this could be enhanced, for example by having some copy attributes from this protection instance method, or maybe even better an additional updateProtection() method that has all properties set like they currently are and then allows to update only the things that should be changed.
There's an update option in the GitHub API so this is doable.
This would be good candidate for using the AbstractBuilder framework.
https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#update-branch-protection
Yeah I too had similar problem. I am bit surprised to see why this API hasn't been implemented to update the ones that are required :(
@PrasannanjaneyuluPadavala-EN0195 PR's welcome.