-
-
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.
Showing
4 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/GitHub/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.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,41 @@ | ||
filter Get-GitHubRepositoryTagProtection { | ||
<# | ||
.SYNOPSIS | ||
List tag protection states for a repository | ||
.DESCRIPTION | ||
This returns the tag protection states of a repository. | ||
This information is only available to repository administrators. | ||
.EXAMPLE | ||
Get-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' | ||
Gets the tag protection states of the 'hello-world' repository. | ||
.NOTES | ||
https://docs.github.com/rest/repos/tags#list-tag-protection-states-for-a-repository | ||
#> | ||
[OutputType([pscustomobject])] | ||
[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) | ||
) | ||
|
||
$inputObject = @{ | ||
APIEndpoint = "/repos/$Owner/$Repo/tags/protection" | ||
Method = 'GET' | ||
} | ||
|
||
Invoke-GitHubAPI @inputObject | ForEach-Object { | ||
Write-Output $_.Response | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/GitHub/public/Repositories/Tags/New-GitHubRepositoryTagProtection.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,49 @@ | ||
filter New-GitHubRepositoryTagProtection { | ||
<# | ||
.SYNOPSIS | ||
Create a tag protection state for a repository | ||
.DESCRIPTION | ||
This creates a tag protection state for a repository. | ||
This endpoint is only available to repository administrators. | ||
.EXAMPLE | ||
New-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -Pattern 'v1.*' | ||
Creates a tag protection state for the 'hello-world' repository with the pattern 'v1.*'. | ||
.NOTES | ||
https://docs.github.com/rest/repos/tags#create-a-tag-protection-state-for-a-repository | ||
#> | ||
[OutputType([pscustomobject])] | ||
[CmdletBinding(SupportsShouldProcess)] | ||
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), | ||
|
||
# An optional glob pattern to match against when enforcing tag protection. | ||
[Parameter(Mandatory)] | ||
[string] $Pattern | ||
) | ||
|
||
$body['pattern'] = $Pattern | ||
|
||
$inputObject = @{ | ||
APIEndpoint = "/repos/$Owner/$Repo/tags/protection" | ||
Method = 'POST' | ||
Body = $body | ||
} | ||
|
||
if ($PSCmdlet.ShouldProcess("tag protection state on pattern [$Pattern] for repository [$Owner/$Repo]", 'Create')) { | ||
Invoke-GitHubAPI @inputObject | ForEach-Object { | ||
Write-Output $_.Response | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/GitHub/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.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,46 @@ | ||
filter Remove-GitHubRepositoryTagProtection { | ||
<# | ||
.SYNOPSIS | ||
Delete a tag protection state for a repository | ||
.DESCRIPTION | ||
This deletes a tag protection state for a repository. | ||
This endpoint is only available to repository administrators. | ||
.EXAMPLE | ||
Remove-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -TagProtectionId 1 | ||
Deletes the tag protection state with the id 1 for the 'hello-world' repository. | ||
.NOTES | ||
https://docs.github.com/rest/repos/tags#delete-a-tag-protection-state-for-a-repository | ||
#> | ||
[OutputType([pscustomobject])] | ||
[CmdletBinding(SupportsShouldProcess)] | ||
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), | ||
|
||
# The unique identifier of the tag protection. | ||
[Parameter(Mandatory)] | ||
[int] $TagProtectionId | ||
) | ||
|
||
$inputObject = @{ | ||
APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId" | ||
Method = 'DELETE' | ||
} | ||
|
||
if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repo]", 'Delete')) { | ||
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