-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Fail build if any git tracked files were modified. (#9661)
When running `xaprepare` on Windows, your local `git` tree ends up dirty due to line ending changes in `THIRD-PARTY-NOTICES.txt`. Update `xaprepare` to always normalize line endings to `Environment.NewLine` in `THIRD-PARTY-NOTICES.txt` to prevent this issue. Additionally, these scenarios where the build unintentionally modifies git tracked files on some platforms are frustrating, so let's prevent them from happening in the first place. Add a CI check to fail a build if any git tracked files were modified. Example: > ❌ **git gree has modified tracked files.**  Clicking the error will show the modified file(s): > "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInte… > HEAD detached at b1a5f77 > Changes not staged for commit: > (use "git add ‹file›..." to update what will be committed) > (use "git restore ‹file›..." to discard changes in working directory) > modified: THIRD-PARTY-NOTICES. TXT > … > ##[error]git tree has modified tracked files. 
- Loading branch information
Showing
5 changed files
with
33 additions
and
1 deletion.
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
22 changes: 22 additions & 0 deletions
22
build-tools/automation/yaml-templates/fail-on-dirty-tree.yaml
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 @@ | ||
# Ensure the build did not produce any modified checked in files | ||
|
||
parameters: | ||
condition: succeeded() | ||
xaSourcePath: | ||
|
||
steps: | ||
- powershell: | | ||
# Run this to log the output for the user | ||
git status | ||
# Run this to error the build if untracked files | ||
$process= git status --porcelain --untracked-files=no | ||
if ($process) | ||
{ | ||
Write-Host "##vso[task.logissue type=error]git tree has modified tracked files." | ||
Write-Host "##vso[task.complete result=Failed;]" | ||
} | ||
displayName: Ensure no modified committed files | ||
workingDirectory: ${{ parameters.xaSourcePath }} | ||
condition: ${{ parameters.condition }} |
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