зеркало из https://github.com/dotnet/razor.git
Git hooks format (#2984)
* Git hooks format * Update build.ps1 Co-authored-by: Allison Chou <allichou@microsoft.com> Co-authored-by: Allison Chou <allichou@microsoft.com>
This commit is contained in:
Родитель
922be0ff0d
Коммит
e510588cfd
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
LC_ALL=C
|
||||
|
||||
# Select files to format
|
||||
FILES=$(git show --name-only --pretty="")
|
||||
[ -z "$FILES" ] && exit 0
|
||||
|
||||
# Format all selected files with dotnet-format
|
||||
echo "dotnet-format: Formatting changed source files.."
|
||||
echo "$FILES" | cat | xargs | sed -e 's/ /,/g' | xargs dotnet-format --folder . --include >/dev/null
|
||||
echo "dotnet-format: $(git diff --cached --numstat | wc -l) file(s) formatted."
|
||||
|
||||
# Add files to staging
|
||||
echo "$FILES" | xargs git add
|
||||
exit 0
|
|
@ -0,0 +1,26 @@
|
|||
# Check dotnet-format is installed or not
|
||||
$dotnetFormat = Get-Command dotnet-format -ErrorAction Ignore -CommandType Application
|
||||
|
||||
if ($dotnetFormat)
|
||||
{
|
||||
Write-Host -f Magenta "dotnet format tool is already installed."
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host -f Magenta "Installing dotnet-format tool.."
|
||||
& dotnet tool install -g dotnet-format
|
||||
}
|
||||
|
||||
# We need to change default git hooks directory as .git folder is not tracked. And by default hooks are stored in .git/hooks folder.
|
||||
# So we are setting git hooks default directory to .githooks, so that we can track and version the git hooks.
|
||||
& git config core.hooksPath .githooks
|
||||
|
||||
& $PSScriptRoot\eng\common\Build.ps1 -restore -build -pack $args
|
||||
function ExitWithExitCode([int] $exitCode) {
|
||||
if ($ci -and $prepareMachine) {
|
||||
Stop-Processes
|
||||
}
|
||||
exit $exitCode
|
||||
}
|
||||
|
||||
ExitWithExitCode $LASTEXITCODE
|
Загрузка…
Ссылка в новой задаче