Functions/Get-HgTag.ps1
function Get-HgTag { <# .SYNOPSIS Gets the tags in a repository. .DESCRIPTION By default, all tags are returned. You can supply a name to return a specific tag, or a wildcard to return multiple tags. .EXAMPLE Get-HgTag Demonstrates how to get all the tags in a repository. .EXAMPLE Get-HgTag -Name 'LastSuccessfulBuild' Demonstrates how to return a specific tag. If no tag matches, then `$null` is returned. .EXAMPLE Get-HgTag -Name '13.8.*' Demonstrates how to return all tags that match a wildcard. #> [CmdletBinding()] [OutputType([PsHg.TagInfo])] param( [Parameter()] [string] # The name of the tag to return. Wildcards accepted. $Name, [Parameter()] [string] # The path to the repository whose tags to get. Defaults to current directory. $RepoRoot = (Get-Location) ) Set-StrictMode -Version 'Latest' $RepoRoot = Resolve-HgRoot -Path $RepoRoot if( -not $RepoRoot ) { return } hg tags -R $RepoRoot --debug | Where-Object { $_ -match '^(.*) +(\d+):([a-f0-9]{40})( local)?$' } | ForEach-Object { New-Object 'PsHg.TagInfo' $Matches[1].TrimEnd(),$Matches[2],$Matches[3],$Matches[4] } | Where-Object { if( $PSBoundParameters.ContainsKey( 'Name' ) ) { return $_.Name -like $Name } return $true } } Set-Alias -Name 'ghgt' -Value 'Get-HgTag' |