Last active
March 14, 2024 09:49
-
-
Save fbouchery/969a7824acf0fc7b5cd6395b1c96a9e5 to your computer and use it in GitHub Desktop.
Extract phpstan baseline history count from GIT
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
<?php | |
$baselineFile = 'phpstan-baseline.neon'; | |
$branch = 'origin/main'; | |
echo "date;count\n"; | |
foreach (explode("\n", `git log {$branch} --pretty="format:%H;%cI" --date-order --reverse {$baselineFile}`) as $line) { | |
[$hash, $date] = explode(';', $line); | |
preg_match_all('`^\s+count:\s+(\d+)`m', `git show $hash:{$baselineFile}`, $matches); | |
echo $date, ';', array_sum(array_map('intval', $matches[1])), "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice 👍
For all which just want to copy & paste it into the terminal:
For line numbers instead of error count: