Skip to content

Enhance Get-GitHubRepositoryTag cmdlet by providing ability to filter results by TagName #46

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

Closed
tristanbarcelon opened this issue Nov 14, 2018 · 3 comments

Comments

@tristanbarcelon
Copy link

This module fits very close to what I needed when querying available tags before finally downloading a release asset using the releases api. It would be even better if there was a way to filter out the tag results by providing an optional parameter to Get-GitHubRepositoryTag:

1). [string[]] TagName
When provided, filter the results by tags that have an exact match with values in the array.

I'm intending to use this cmdlet to find the existence of matching tags. When they do exist, then I can call the releases api and filter by assets names to download.

Thanks in advance.

@tristanbarcelon tristanbarcelon changed the title Provide the ability to filter Get-GitHubRepositoryTag cmdlet results Enhance Get-GitHubRepositoryTag cmdlet by providing ability to filter results by TagName Nov 14, 2018
@HowardWolosky
Copy link
Contributor

HowardWolosky commented Nov 14, 2018

Thanks for the suggestion, Tristan. The beauty of PowerShell is how easily it lets you process data through piping. In this case, the way to achieve what you want is to filter the results through Where-Object afterwards. Example:

Get-GitHubRepositoryTag -OwnerName PowerShell -RepositoryName PowerShellForGitHub | Where-Object { $_.name -like '0.3.*' }

Given that this can be done naturally through PowerShell via post-processing, it's not something that makes sense to add explicitly to the function itself.

Thanks!

@HowardWolosky
Copy link
Contributor

To even more closely match your explicit request:

$tagNames = @('0.3.0', '0.2.0')
$tags = Get-GitHubRepositoryTag -OwnerName PowerShell -RepositoryName PowerShellForGitHub
$tags | Where-Object { $_.name -in $tagNames }

@tristanbarcelon
Copy link
Author

I agree with your suggestion and it works well for the purpose mentioned. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants