Public/Get-CCProjectVersion.ps1

function Get-CCProjectVersion {
    <#
    .SYNOPSIS
        Reads a repository's version: its latest version tag, with every manifest that repeats it.
    .DESCRIPTION
        The git tag is the version. The answer is the latest version tag reachable from HEAD, whether
        HEAD is that tag, and every module manifest or project file that states a version, with whether
        it agrees. A repository that has never been tagged answers from its manifest, and says so in
        Source.
    .EXAMPLE
        Get-CCProjectVersion -Path .
    .EXAMPLE
        (Get-CCProjectVersion).Manifests | Where-Object { -not $_.Agrees }
    #>

    [CmdletBinding()]
    [OutputType([pscustomobject])]
    param(
        [Parameter(Position = 0)]
        [string]$Path = '.'
    )

    $full = (Resolve-Path -LiteralPath $Path).Path
    $reading = [CodeCompass.Core.VersionService]::new().GetVersion($full)
    $disagreeing = @($reading.Disagreeing | ForEach-Object { $_.RelativePath })

    [pscustomobject]@{
        Technology = $reading.Context.Technology.ToString()
        Version    = $reading.Version.ToString()
        Source     = $reading.Source.ToString()
        Tag        = $reading.Tag
        OnTag      = $reading.HeadIsTag
        Agrees     = $disagreeing.Count -eq 0
        Manifests  = @($reading.Manifests | ForEach-Object {
                [pscustomobject]@{
                    Path    = $_.RelativePath
                    Version = $_.Value
                    Agrees  = $_.RelativePath -notin $disagreeing
                }
            })
        Path       = $reading.Context.RootPath
    }
}