Skip to content

Commit 9ee1068

Browse files
author
Bart Koelman
committed
Fix failing builds during force-pushes
1 parent 82ce4a3 commit 9ee1068

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Build.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ function RunCleanupCode {
3939
# When running in cibuild for a pull request, this reformats only the files changed in the PR and fails if the reformat produces changes.
4040

4141
if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) {
42-
Write-Output "Running code cleanup in cibuild for pull request"
42+
Write-Output "Running code cleanup on changed files in pull request"
4343

44-
$sourceCommitHash = $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT
44+
# In the past, we used $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT for the merge commit hash. That is the pinned hash at the time the build is enqueued.
45+
# When a force-push happens after that, while the build hasn't yet started, this hash becomes invalid during the build, resulting in a lookup error.
46+
# To prevent failing the build for unobvious reasons we use HEAD, which is always the latest version.
47+
$mergeCommitHash = git rev-parse "HEAD"
4548
$targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
4649

47-
Write-Output "Source commit hash = $sourceCommitHash"
48-
Write-Output "Target commit hash = $targetCommitHash"
49-
50-
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $sourceCommitHash -b $targetCommitHash --fail-on-diff --print-diff
50+
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff
5151
CheckLastExitCode
5252
}
5353
}

0 commit comments

Comments
 (0)