@@ -54,6 +54,56 @@ function Resolve-ToolPath {
5454 throw " Required command not found: $Name "
5555}
5656
57+ function Get-CleanTrackedConfigFiles {
58+ param ([string ]$RepoRoot )
59+
60+ $trackedConfigFiles = & git - C $RepoRoot ls- files -- ' Config/*.ini'
61+ if ($LASTEXITCODE -ne 0 ) {
62+ throw ' Failed to enumerate tracked config files.'
63+ }
64+
65+ $cleanConfigFiles = @ ()
66+ foreach ($relativePath in $trackedConfigFiles ) {
67+ $isDirty = & git - C $RepoRoot diff -- quiet -- $relativePath
68+ if ($LASTEXITCODE -eq 0 ) {
69+ $cleanConfigFiles += $relativePath
70+ continue
71+ }
72+ if ($LASTEXITCODE -eq 1 ) {
73+ continue
74+ }
75+ throw " Failed to inspect config file dirtiness: $relativePath "
76+ }
77+
78+ return $cleanConfigFiles
79+ }
80+
81+ function Restore-GeneratedConfigChanges {
82+ param (
83+ [string ]$RepoRoot ,
84+ [string []]$RelativePaths
85+ )
86+
87+ foreach ($relativePath in $RelativePaths ) {
88+ & git - C $RepoRoot diff -- quiet -- $relativePath
89+ if ($LASTEXITCODE -eq 0 ) {
90+ continue
91+ }
92+ if ($LASTEXITCODE -ne 1 ) {
93+ throw " Failed to inspect post-verify config dirtiness: $relativePath "
94+ }
95+
96+ & git - C $RepoRoot restore -- source= HEAD -- worktree -- $relativePath
97+ if ($LASTEXITCODE -ne 0 ) {
98+ throw " Failed to restore generated config drift: $relativePath "
99+ }
100+ }
101+ }
102+
103+ $repoRoot = $null
104+ $cleanTrackedConfigFiles = @ ()
105+ $exitCode = 0
106+
57107try {
58108 $repoRoot = (Resolve-Path $PSScriptRoot ).Path
59109 Set-Location $repoRoot
@@ -75,14 +125,16 @@ try {
75125 Write-Info " Repo: $repoRoot "
76126 Write-Info " UE: $ueVersion ($engineRoot )"
77127
128+ $cleanTrackedConfigFiles = Get-CleanTrackedConfigFiles - RepoRoot $repoRoot
129+
78130 if (-not $SkipFormat ) {
79131 Write-Info ' Running C++ format check (clang-format --dry-run --Werror) ...'
80132 $clangFormat = Resolve-ToolPath - Name ' clang-format' - EngineRoot $engineRoot
81133 $pluginSrcDir = Join-Path $repoRoot ' Plugins\RuntimeAssetImport\Source'
82134 if (Test-Path - LiteralPath $pluginSrcDir ) {
83135 $formatExtensions = @ (' .h' , ' .hh' , ' .hpp' , ' .cpp' , ' .cc' , ' .cxx' )
84136 $formatFiles = & git - C (Join-Path $repoRoot ' Plugins\RuntimeAssetImport' ) ls- files -- ' Source'
85- foreach ($file in ($formatFiles | Where-Object { $formatExtensions -contains [IO.Path ]::GetExtension($_ ) })) {
137+ foreach ($file in ($formatFiles | Where-Object { $formatExtensions -contains [IO.Path ]::GetExtension($_ ) -and $_ -notlike ' Source/ThirdParty/* ' })) {
86138 $fullPath = Join-Path (Join-Path $repoRoot ' Plugins\RuntimeAssetImport' ) $file
87139 & $clangFormat -- dry- run -- Werror -- style= file $fullPath
88140 if ($LASTEXITCODE -ne 0 ) { throw " clang-format check failed: $file " }
@@ -115,9 +167,16 @@ try {
115167 }
116168
117169 Write-Info ' VERIFY PASSED'
118- exit 0
170+ $exitCode = 0
119171}
120172catch {
121173 Write-Err $_.Exception.Message
122- exit 1
174+ $exitCode = 1
123175}
176+ finally {
177+ if ($null -ne $repoRoot -and $cleanTrackedConfigFiles.Count -gt 0 ) {
178+ Restore-GeneratedConfigChanges - RepoRoot $repoRoot - RelativePaths $cleanTrackedConfigFiles
179+ }
180+ }
181+
182+ exit $exitCode
0 commit comments