Skip to content

Commit

Permalink
cleanup git magic
Browse files Browse the repository at this point in the history
  • Loading branch information
Rondom committed Nov 3, 2016
1 parent 5a7132f commit 8624c88
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,39 +280,29 @@
# AppVeyor does not provide us with the SHA1 before the push
# Thus we have no baseline for pushes and can only run this for PRs
if ($env:CONFIGURATION -eq "All" -and $env:APPVEYOR_PULL_REQUEST_NUMBER) {
$parents = (& git rev-list --parents -n1 HEAD).Split()
$parents = (Exec-External {& git rev-list --parents -n1 HEAD}).Split()
$head = $parents[0]
$mergeBranchHead = $parents[1]
$prBranchHead = $parents[2]
$mergeBase = (& git merge-base HEAD $mergeBranchHead)
Write-Host $parents
Write-Host $mergeBase
if ($mergeBase) {
# HEAD is the rev of the merge-commit, so HEAD^ is the HEAD of the PR branch
$diffFile = "clang_format_${prBranchHead}_${mergeBranchHead}.diff"
Exec-External {& git clang-format --style=file --diff $mergeBase} |
Select-String -NotMatch "^clang-format did not modify any files$" > $diffFile
if ((Get-Item $diffFile).length -gt 0) {
Write-Host "Ran git clang-format on PR, found changes, uploading as artifact"
Add-AppveyorMessage `
-Category Warning `
-Message "Please check your indentation." `
-Details ("You may want to run ``git clang-format --style file`` on each of your commits." + `
"A diff of the suggested changes is available here:" + `
"https://ci.appveyor.com/api/buildjobs/$([System.Web.HttpUtility]::UrlEncode($env:APPVEYOR_JOB_ID))/artifacts/$([System.Web.HttpUtility]::UrlEncode($diffFile))")
Push-AppveyorArtifact $diffFile
}
else {
Write-Host "Ran git clang-format on PR, no changes necessary"
Add-AppveyorMessage `
-Category Information `
-Message "Your indentation is fine. clang-format did not suggest any changes."
}
$diffFile = "clang_format_$(& git rev-parse --short $prBranchHead)_into_$(& git rev-parse --short $mergeBranchHead).diff"
Exec-External {& git clang-format --style=file --diff $mergeBranchHead} |
Select-String -NotMatch "^clang-format did not modify any files$" > $diffFile
if ((Get-Item $diffFile).length -gt 0) {
Write-Host "Ran git clang-format on PR, found changes, uploading as artifact"
Add-AppveyorMessage `
-Category Warning `
-Message "Please check your indentation." `
-Details ("You may want to run ``git clang-format --style file`` on each of your commits." + `
"A diff of the suggested changes is available here:" + `
"https://ci.appveyor.com/api/buildjobs/$([System.Web.HttpUtility]::UrlEncode($env:APPVEYOR_JOB_ID))/artifacts/$([System.Web.HttpUtility]::UrlEncode($diffFile))")
Push-AppveyorArtifact $diffFile
}
else {
Write-Host "Ran git clang-format on PR, no changes necessary"
Add-AppveyorMessage `
-Category Warning `
-Message "Could not find merge-base needed for running clang-format"
-Category Information `
-Message "Your indentation is fine. clang-format did not suggest any changes."
}
}
- ps: |
Expand Down

0 comments on commit 8624c88

Please sign in to comment.