Record exact Git blob equality before restoring generated line endings
This commit is contained in:
+8
-3
@@ -49,11 +49,16 @@ try {
|
|||||||
$record.apkMetadata = Join-Path $evidenceDir 'apk-metadata.json'
|
$record.apkMetadata = Join-Path $evidenceDir 'apk-metadata.json'
|
||||||
# Unity rewrites these files with LF; restore only when Git proves their content is unchanged.
|
# Unity rewrites these files with LF; restore only when Git proves their content is unchanged.
|
||||||
$record.normalizedUnchangedSettings = @()
|
$record.normalizedUnchangedSettings = @()
|
||||||
|
$record.settingsContentChecks = @()
|
||||||
if (!$record.sourceDirty) {
|
if (!$record.sourceDirty) {
|
||||||
foreach ($settingsPath in @('ProjectSettings/GraphicsSettings.asset','ProjectSettings/ProjectAuditorSettings.asset','ProjectSettings/ProjectSettings.asset')) {
|
foreach ($settingsPath in @('ProjectSettings/GraphicsSettings.asset','ProjectSettings/ProjectAuditorSettings.asset','ProjectSettings/ProjectSettings.asset')) {
|
||||||
& git diff --quiet HEAD -- $settingsPath
|
$workingBlob = & git hash-object --path=$settingsPath -- $settingsPath
|
||||||
if ($LASTEXITCODE -eq 0 -and [bool](& git status --porcelain -- $settingsPath)) {
|
$workingExit = $LASTEXITCODE
|
||||||
& git restore --worktree -- $settingsPath
|
$sourceBlob = & git rev-parse "HEAD:$settingsPath"
|
||||||
|
$sourceExit = $LASTEXITCODE
|
||||||
|
$record.settingsContentChecks += @{ path=$settingsPath; workingBlob=$workingBlob; sourceBlob=$sourceBlob; hashObjectExit=$workingExit; revParseExit=$sourceExit }
|
||||||
|
if ($workingExit -eq 0 -and $sourceExit -eq 0 -and $workingBlob -eq $sourceBlob -and [bool](& git status --porcelain -- $settingsPath)) {
|
||||||
|
& git restore --source=HEAD --worktree -- $settingsPath
|
||||||
if ($LASTEXITCODE -ne 0) { throw "Cannot restore unchanged generated setting: $settingsPath" }
|
if ($LASTEXITCODE -ne 0) { throw "Cannot restore unchanged generated setting: $settingsPath" }
|
||||||
$record.normalizedUnchangedSettings += $settingsPath
|
$record.normalizedUnchangedSettings += $settingsPath
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user