-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23dd302
commit 6564da8
Showing
3 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
src/GitHub/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
filter Get-GitHubRepositoryCodeownersError { | ||
<# | ||
.SYNOPSIS | ||
List CODEOWNERS errors | ||
.DESCRIPTION | ||
List any syntax errors that are detected in the CODEOWNERS file. | ||
For more information about the correct CODEOWNERS syntax, | ||
see "[About code owners](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)." | ||
.EXAMPLE | ||
Get-GitHubRepositoryCodeownersError -Owner 'PSModule' -Repo 'GitHub' | ||
Gets the CODEOWNERS errors for the repository. | ||
.NOTES | ||
https://docs.github.com/rest/repos/repos#list-codeowners-errors | ||
#> | ||
[CmdletBinding()] | ||
param ( | ||
# The account owner of the repository. The name is not case sensitive. | ||
[Parameter()] | ||
[Alias('org')] | ||
[string] $Owner = (Get-GitHubConfig -Name Owner), | ||
|
||
# The name of the repository without the .git extension. The name is not case sensitive. | ||
[Parameter()] | ||
[string] $Repo = (Get-GitHubConfig -Name Repo), | ||
|
||
# A branch, tag or commit name used to determine which version of the CODEOWNERS file to use. | ||
# Default: the repository's default branch (e.g. main) | ||
[Parameter()] | ||
[string] $Ref | ||
) | ||
|
||
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object { | ||
$paramName = $_.Key | ||
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue | ||
$providedValue = $PSBoundParameters[$paramName] | ||
Write-Verbose "[$paramName]" | ||
Write-Verbose " - Default: [$paramDefaultValue]" | ||
Write-Verbose " - Provided: [$providedValue]" | ||
if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) { | ||
Write-Verbose ' - Using default value' | ||
$PSBoundParameters[$paramName] = $paramDefaultValue | ||
} else { | ||
Write-Verbose ' - Using provided value' | ||
} | ||
} | ||
|
||
$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case | ||
Remove-HashtableEntries -Hashtable $body -RemoveNames 'Owner','Repo' -RemoveTypes 'SwitchParameter' | ||
|
||
$inputObject = @{ | ||
APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors" | ||
Method = 'GET' | ||
Body = $body | ||
} | ||
|
||
Invoke-GitHubAPI @inputObject | ForEach-Object { | ||
Write-Output $_.Response | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters