2019-06-11 16:23:21 -07:00
|
|
|
|
|
|
|
|
#.SYNOPSIS
|
|
|
|
|
# Checks for code formatting errors. Will throw exception if any are found.
|
|
|
|
|
function Invoke-CheckBadCodeFormatting() {
|
|
|
|
|
Import-Module ./tools/OpenConsole.psm1
|
2021-03-29 17:09:38 -05:00
|
|
|
|
|
|
|
|
# Don't run the XAML formatter in this step - even if it changes nothing,
|
|
|
|
|
# it'll still touch all the .xaml files.
|
|
|
|
|
Invoke-CodeFormat -IgnoreXaml
|
|
|
|
|
|
2019-06-11 16:23:21 -07:00
|
|
|
# returns a non-zero exit code if there are any diffs in the tracked files in the repo
|
|
|
|
|
git diff-index --quiet HEAD --
|
2023-06-30 16:18:35 +02:00
|
|
|
if ($LASTEXITCODE -eq 1) {
|
2021-03-29 17:09:38 -05:00
|
|
|
|
|
|
|
|
# Write the list of files that need updating to the log
|
|
|
|
|
git diff-index --name-only HEAD
|
|
|
|
|
|
2019-06-11 16:23:21 -07:00
|
|
|
throw "code formatting bad, run Invoke-CodeFormat on branch"
|
|
|
|
|
}
|
2021-03-29 17:09:38 -05:00
|
|
|
|
|
|
|
|
# Manually check the formatting of our .xaml files, without touching them.
|
2021-05-21 13:11:54 -03:00
|
|
|
Test-XamlFormat
|
2021-03-29 17:09:38 -05:00
|
|
|
|
2019-06-11 16:23:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Invoke-CheckBadCodeFormatting
|