Skip to content

Instantly share code, notes, and snippets.

@fbouchery
fbouchery / extract.php
Last active March 14, 2024 09:49
Extract phpstan baseline history count from GIT
<?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";
}