-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PR validation for formatting (#416)
* Intentionally breaking the formatting * Add script to run clang-format only to changes * Not working with staged files? * Here goes nothing * Okay, the job name was that way for a reason. Mystery solved * Why won't it show my output? * Oh fun, whack-a-mole * Maybe it was the backticks? * Oh, it was probably the angly brackets * Parenthesis need escaping too I guess * Formatting back * Update the readme
- Loading branch information
Showing
6 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@echo off | ||
:: NOTE: No 'setlocal' since we're "returning" the definition of "CLANG_FORMAT" to the caller | ||
|
||
:: Clang format's behavior has changed over time, meaning that different machines with different versions of LLVM | ||
:: installed may get different formatting behavior. In an attempt to ensure consistency, we use the clang-format.exe | ||
:: that ships with Visual Studio. There may still be issues if two different machines have different versions of Visual | ||
:: Studio installed, however this will hopefully improve things | ||
set CLANG_FORMAT=%VCINSTALLDIR%\Tools\Llvm\bin\clang-format.exe | ||
if not exist "%CLANG_FORMAT%" ( | ||
set CLANG_FORMAT= | ||
echo ERROR: clang-format.exe not found at %%VCINSTALLDIR%%\Tools\Llvm\bin\clang-format.exe | ||
echo ERROR: Ensure that this script is being run from a Visual Studio command prompt | ||
exit /B 1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@echo off | ||
setlocal | ||
setlocal EnableDelayedExpansion | ||
|
||
set PROJECT_ROOT=%~dp0\.. | ||
|
||
set BRANCH=%1 | ||
if "%BRANCH%"=="" ( | ||
echo ERROR: Missing commit/branch argument. If this is a fork of the microsoft/wil repo, you likely want to specify | ||
echo 'upstream/master'. If this is not a fork, you likely want to specify 'origin/master'. Examples: | ||
echo. | ||
echo format-changes.cmd origin/master | ||
echo format-changes.cmd upstream/master | ||
exit /b 1 | ||
) | ||
|
||
call "%~dp0/find-clang-format.cmd" | ||
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL% | ||
|
||
pushd %PROJECT_ROOT% > NUL | ||
git clang-format %BRANCH% --binary "%CLANG_FORMAT%" --style file -- include/wil/*.h tests/*.h tests/*.cpp | ||
popd > NUL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters