Commit b13fa619 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Utilise la date de dernier commit plutôt que la date courante pour les copyrights.

Ça devrait limiter les faux positifs quand on teste un "vieux" code.
No related merge requests found
Showing with 14 additions and 5 deletions
+14 -5
......@@ -45,12 +45,21 @@ final class GitRepository implements GitRepositoryInterface
*/
public function getYearRange(): string
{
$last = date('Y');
$first = exec('git -C ' . escapeshellarg($this->repositoryPath) . ' log --format=%cd --date=format:%Y --date-order | tail -n1');
if (!$first) {
$first = '???';
$years = [];
exec(
sprintf(
'git -C %s log --format=%%cd --date=format:%%Y --date-order %s | sed \'1p;$p;d\'',
escapeshellarg($this->repositoryPath),
escapeshellarg($this->getHeadCommit())
),
$years
);
if (!$years) {
return '???';
}
$last = trim(array_shift($years));
$first = $years ? trim(array_pop($years)) : $last;
return ($last !== null && $last !== $first) ? "$first-$last" : $first;
return $last !== $first ? "$first-$last" : $first;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment