-
Notifications
You must be signed in to change notification settings - Fork 191
New GitHubRepositoryBranchProtectionRule Functions #238
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
New GitHubRepositoryBranchProtectionRule Functions #238
Conversation
Can we trigger the CI for this PR? |
/azp run PowerShellForGitHub-CI |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos for your work on trying to adapt this very complicated API into a function.
In addition to the needed work to adapt for pipeline support, I have a number of pieces of feedback for you to consider before this can get merged in.
Thanks again for all your effort!
$RestrictPushTeams = @() | ||
} | ||
|
||
$restrictions = @{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my feedback above regarding required_status_checks
, this will introduce regressions if users try to update just the push users or just the teams. If I already have values defined for users, and now I go and want to make a separate call to set the teams, this code, as written, will wipe out my defined users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub have really over-complicated this API and it doesn't allow you to do this. To achieve this functionality, all the other individual API endpoints would need to be implemented. I was originally thinking of making this function New-GitHubRepositoryBranchProtectionRule
and am happy to go back to that if required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow. You've already implemented Get-GitHubRepositoryBranchProtectionRule
. If you detected that any of these object properties were being altered and called that first, wouldn't you have all the content that you'd need in order to ensure you weren't overwriting any property that the user didn't provide in this call?
@X-Guardian - please be sure to @ mention me once this is ready for the next review (there are so many of your reviews for me to keep track of). Thanks again for all your work. Much appreciated! |
Specify which users have push access. | ||
|
||
.PARAMETER RestrictPushTeams | ||
Specify which teams have push access. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And actually, saying that and then reviewing the code, it occurs to me that you don't have OrganizationName
as a parameter, which means that users can't specify team names that are owned by an organization, which could be a problem if the repo that the rule is being applied to is one owned by an organization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's still some iteration to go through, between these new comments and the existing unresolved threads we have going on.
Again though, I really appreciate your efforts here.
$RestrictPushTeams = @() | ||
} | ||
|
||
$restrictions = @{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow. You've already implemented Get-GitHubRepositoryBranchProtectionRule
. If you detected that any of these object properties were being altered and called that first, wouldn't you have all the content that you'd need in order to ensure you weren't overwriting any property that the user didn't provide in this call?
|
||
if ($PSBoundParameters.ContainsKey('StatusChecks')) | ||
{ | ||
$requiredStatusChecks = @{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would define $requiredStatusChecks = $null
outside of the if
, and then you won't need the else
at all.
We don't currently have strict mode on right now, but I still prefer to code that way. The way you have it right now, you're declaring a variable within the if
scope, so while PowerShell allows it to be accessed outside of that scope, it's still not a great practice to follow. You generally want to be declaring/initially using your variables in the scope you're intending to use them, which in thi scase, is outside of the if
scope.
This PR is superseded by PR #255 |
Description
This PR adds the following GitHub Branch Protection Rule functions to the
GitHubBranches
module:Get-GitHubRepositoryBranchProtectionRule
Set-GitHubRepositoryBranchProtectionRule
Remove-GitHubRepositoryBranchProtectionRule
The
lukeCageAcceptHeader
was also added to theGitHubCore
module with a value ofapplication/vnd.github.luke-cage-preview+json
.Issues Fixed
None
References
GitHub REST API v3
Checklist
If desired, ensure your name is added to our Contributors list