Skip to content

Commit

Permalink
GitHubBranches: Add Get/New/Remove GitHub Repository Branch Pattern P…
Browse files Browse the repository at this point in the history
…rotection Rule (#313)

Adds the following functions to the `GitHubBranches` module:

* `Invoke-GHGraphQl`
* `Get-GitHubRepositoryBranchPatternProtectionRule`
* `New-GitHubRepositoryBranchPatternProtectionRule`
* `Remove-GitHubRepositoryBranchPatternProtectionRule`

`Invoke-GHGraphQl` is based on `Invoke-GHRestMethod` but modified with the following features:

* Use of the GitHub GraphQL API Endpoint.
* PowerShell 5 and 6+ `Invoke-WebRequest` error handling support.
* Use of `ThrowTerminatingError` instead of `Throw` for enhanced exceptions and hiding the internal details of the function. Reference: [Everything you wanted to know about exceptions](https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-exceptions)
* GraphQl specific error handling.
* Extensive debug logging.

Fixes #312 

References
* [createbranchprotectionrule](https://docs.github.com/en/graphql/reference/mutations#createbranchprotectionrule)
* [deletebranchprotectionrule](https://docs.github.com/en/graphql/reference/mutations#deletebranchprotectionrule)
* [branchprotectionrule](https://docs.github.com/en/graphql/reference/objects#branchprotectionrule)
  • Loading branch information
X-Guardian authored Jul 15, 2021
1 parent 0ebf9e8 commit f7efc4a
Show file tree
Hide file tree
Showing 9 changed files with 2,422 additions and 85 deletions.
74 changes: 74 additions & 0 deletions Formatters/GitHubBranches.Format.ps1xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<!--=============== GitHub.BranchPatternProtectionRule Type View ===============-->
<View>
<Name>GitHub.BranchPatternProtectionRule</Name>
<ViewSelectedBy>
<TypeName>GitHub.BranchPatternProtectionRule</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>RepositoryUrl</PropertyName>
</ListItem>
<ListItem>
<PropertyName>pattern</PropertyName>
</ListItem>
<ListItem>
<PropertyName>requiredApprovingReviewCount</PropertyName>
</ListItem>
<ListItem>
<PropertyName>dismissesStaleReviews</PropertyName>
</ListItem>
<ListItem>
<PropertyName>requiresCodeOwnerReviews</PropertyName>
</ListItem>
<ListItem>
<PropertyName>DismissalTeams</PropertyName>
</ListItem>
<ListItem>
<PropertyName>DismissalUsers</PropertyName>
</ListItem>
<ListItem>
<PropertyName>requiresStatusChecks</PropertyName>
</ListItem>
<ListItem>
<PropertyName>requiresStrictStatusChecks</PropertyName>
</ListItem>
<ListItem>
<PropertyName>requiredStatusCheckContexts</PropertyName>
</ListItem>
<ListItem>
<PropertyName>requiresCommitSignatures</PropertyName>
</ListItem>
<ListItem>
<PropertyName>requiresLinearHistory</PropertyName>
</ListItem>
<ListItem>
<PropertyName>isAdminEnforced</PropertyName>
</ListItem>
<ListItem>
<PropertyName>RestrictPushApps</PropertyName>
</ListItem>
<ListItem>
<PropertyName>RestrictPushTeams</PropertyName>
</ListItem>
<ListItem>
<PropertyName>RestrictPushUsers</PropertyName>
</ListItem>
<ListItem>
<PropertyName>allowsForcePushes</PropertyName>
</ListItem>
<ListItem>
<PropertyName>allowsDeletions</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
Loading

0 comments on commit f7efc4a

Please sign in to comment.