Keep track of commit dates in the lock file in case the reference disappears
parent
77f6b9e05b
commit
c9ef7479c4
|
@ -144,7 +144,7 @@ class Factory
|
|||
$lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
|
||||
? substr($composerFile, 0, -4).'lock'
|
||||
: $composerFile . '.lock';
|
||||
$locker = new Package\Locker(new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, md5_file($composerFile));
|
||||
$locker = new Package\Locker(new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, $im, md5_file($composerFile));
|
||||
$composer->setLocker($locker);
|
||||
}
|
||||
|
||||
|
|
|
@ -401,6 +401,10 @@ class Installer
|
|||
$lockData = $this->locker->getLockData();
|
||||
foreach ($lockData['packages'] as $lockedPackage) {
|
||||
if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
|
||||
// update commit date to allow recovery in case the commit disappeared
|
||||
if (!empty($lockedPackage['commit-date'])) {
|
||||
$package->setReleaseDate(new \DateTime('@'.$lockedPackage['commit-date']));
|
||||
}
|
||||
$package->setSourceReference($lockedPackage['source-reference']);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -13,18 +13,22 @@
|
|||
namespace Composer\Package;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Installer\InstallationManager;
|
||||
use Composer\Repository\RepositoryManager;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\Package\AliasPackage;
|
||||
|
||||
/**
|
||||
* Reads/writes project lockfile (composer.lock).
|
||||
*
|
||||
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class Locker
|
||||
{
|
||||
private $lockFile;
|
||||
private $repositoryManager;
|
||||
private $installationManager;
|
||||
private $hash;
|
||||
private $lockDataCache;
|
||||
|
||||
|
@ -33,12 +37,14 @@ class Locker
|
|||
*
|
||||
* @param JsonFile $lockFile lockfile loader
|
||||
* @param RepositoryManager $repositoryManager repository manager instance
|
||||
* @param InstallationManager $installationManager installation manager instance
|
||||
* @param string $hash unique hash of the current composer configuration
|
||||
*/
|
||||
public function __construct(JsonFile $lockFile, RepositoryManager $repositoryManager, $hash)
|
||||
public function __construct(JsonFile $lockFile, RepositoryManager $repositoryManager, InstallationManager $installationManager, $hash)
|
||||
{
|
||||
$this->lockFile = $lockFile;
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->installationManager = $installationManager;
|
||||
$this->hash = $hash;
|
||||
}
|
||||
|
||||
|
@ -217,6 +223,13 @@ class Locker
|
|||
|
||||
if ($package->isDev() && !$alias) {
|
||||
$spec['source-reference'] = $package->getSourceReference();
|
||||
if ('git' === $package->getSourceType()) {
|
||||
$path = $this->installationManager->getInstallPath($package);
|
||||
$process = new ProcessExecutor();
|
||||
if (0 === $process->execute('git log -n1 --pretty=%ct '.escapeshellarg($package->getSourceReference()), $output, $path)) {
|
||||
$spec['commit-date'] = trim($output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($alias) {
|
||||
|
|
Loading…
Reference in New Issue