Created
December 1, 2023 19:11
-
-
Save RReverser/60032effbd90d11183da9b679d808e41 to your computer and use it in GitHub Desktop.
Bisect list of files within a large commit
This file contains hidden or 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
$files = git diff --name-only main | |
# Binary search for a file that causes `./test/runner other.test_closure_type_annotations` to fail. | |
# At each step, try to revert half of the files to `main` branch. | |
# In the end $files will contain only the files that cause the test to fail. | |
while ($files.Length -gt 1) { | |
Write-Output "Testing $($files.Length) files:" | |
$files | ForEach-Object { Write-Output " $_" } | |
$mid = [math]::floor($files.Length / 2) | |
$lower = $files[0..($mid - 1)] | |
$upper = $files[$mid..$files.Length] | |
git checkout main -- $lower | |
git checkout -- $upper | |
./test/runner other.test_closure_type_annotations | |
if ($?) { | |
git checkout -- $lower | |
git checkout main -- $upper | |
./test/runner other.test_closure_type_annotations | |
if ($?) { | |
# If both variants succeeded, we're splitting incorrectly - there's a dependency between files. | |
# Shuffle them and try again. | |
$files = $files | Sort-Object {Get-Random} | |
} else { | |
$files = $lower | |
} | |
} else { | |
$files = $upper | |
} | |
git reset --hard | |
} | |
# Print the file that causes the test to fail. | |
$files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment