Skip to content

Commit

Permalink
Added get repotags
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Oct 9, 2023
1 parent fd49a9f commit ac30a81
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
filter Get-GitHubRepositoryTags {
<#
.SYNOPSIS
List repository tags
.DESCRIPTION
List repository tags
.EXAMPLE
Get-GitHubRepositoryTags -Owner 'PSModule' -Repo 'GitHub'
Gets all tags of the GitHub repository.
.NOTES
https://docs.github.com/rest/repos/repos#list-repository-tags
#>
[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),

# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
[int] $PerPage = 30
)

$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntries -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'

$inputObject = @{
APIEndpoint = "/repos/$Owner/$Repo/tags"
Method = 'GET'
Body = $body
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}
2 changes: 1 addition & 1 deletion tools/utilities/GitHubAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $response = Invoke-RestMethod -Uri $APIDocURI -Method Get
# @{n = 'PUT'; e = { (($_.value.psobject.Properties.Name) -contains 'PUT') } }, `
# @{n = 'PATCH'; e = { (($_.value.psobject.Properties.Name) -contains 'PATCH') } } | Format-Table

$path = '/repos/{owner}/{repo}/contributors'
$path = '/repos/{owner}/{repo}/teams'
$method = 'get'
$response.paths.$path.$method
$response.paths.$path.$method.tags | clip # -> Namespace/foldername
Expand Down

0 comments on commit ac30a81

Please sign in to comment.