protected function checkRepository($package, $targetFolder)
{
if ($package->getSourceType() == 'git') {
$command = sprintf('cd %s && git rev-parse refs/tags/%s', escapeshellarg($this->normalizePath($targetFolder)), escapeshellarg($package->getSourceReference()));
$existingTags = shell_exec($command);
if (!$existingTags) {
$command = sprintf('cd %s && git fetch', escapeshellarg($this->normalizePath($targetFolder)));
shell_exec($command);
}
} elseif ($package->getSourceType() == 'hg') {
$command = sprintf('cd %s && hg log --template "{tags}" -r %s', escapeshellarg($targetFolder), escapeshellarg($package->getSourceReference()));
$existingTag = shell_exec($command);
if ($existingTag === $package->getSourceReference()) {
$command = sprintf('cd %s && hg pull', escapeshellarg($targetFolder));
shell_exec($command);
}
}
}