aboutsummaryrefslogtreecommitdiff
path: root/scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1
blob: 6e97ba35c7f74f326d2bdbd6f42ae014fe50139d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
[CmdletBinding()]
Param(
    [Parameter(Mandatory=$True)]
    [string]$Root,
    [Parameter()]
    [switch]$IgnoreErrors # allows one to just format
)

$portsTree = Get-Item "$Root/ports"

if (-not (Test-Path "$Root/.vcpkg-root"))
{
    Write-Error "The vcpkg root was not at $Root"
    throw
}

if (-not (Test-Path "$Root/vcpkg.exe"))
{
    & "$Root/bootstrap-vcpkg.bat"
    if (-not $?)
    {
        Write-Error "Bootstrapping vcpkg failed"
        throw
    }
}

& "$Root/vcpkg.exe" 'x-format-manifest' '--all'
if (-not $?)
{
    Write-Error "Failed formatting manifests; are they well-formed?"
    throw
}

$changedFiles = & "$PSScriptRoot/Get-ChangedFiles.ps1" -Directory $portsTree
if (-not $IgnoreErrors -and $null -ne $changedFiles)
{
    $msg = @(
        "",
        "The formatting of the manifest files didn't match our expectation.",
        "See https://github.com/microsoft/vcpkg/blob/master/docs/maintainers/maintainer-guide.md#manifest for solution."
    )
    $msg += ""

    $msg += "vcpkg should produce the following diff:"
    $msg += git diff $portsTree

    Write-Error ($msg -join "`n")
    throw
}