Newer
Older
use LakeDrops\Component\Composer\BaseHandler;
/**
* Class Handler.
*
* @package LakeDrops\DorgFlow
*/
class Handler extends BaseHandler {
/**
* Post install/update event to prepare projects for development.

jurgenhaas
committed
if (empty($options['projects'])) {
return;
}

jurgenhaas
committed
$this->io->write('Dorgflow: Preparing drupol.org packages for development', TRUE);
$installationManager = $this->composer->getInstallationManager();
foreach ($options['projects'] as $project => $version) {
$package = $this->getPackage($project);
continue;
}
$path = $installationManager->getInstallPath($package);

jurgenhaas
committed
$this->io->write("- $project => $path", TRUE);
$this->prepareWorkingDirectory($path, $project, $version);
* Retrieve options from composer.json "extra" configuration.
$extra = $this->composer->getPackage()->getExtra() + ['dorgflow' => []];
return $extra['dorgflow'] + [
* Prepare the working directory of a git based package for dorgflow.
*
* @param string $path
* Name of the working directory.
* @param string $project
* Name of the project.
* @param string $version
* Version to checkout.
protected function prepareWorkingDirectory($path, $project, $version) {
$uri = 'git@git.drupal.org:project/' . $projectname . '.git';

jurgenhaas
committed
try {
$origin = $repository->getRemote('origin', FALSE);
if ($origin && $origin->getFetchURL() === $uri) {

jurgenhaas
committed
// Already setup correctly.
return;

jurgenhaas
committed
catch (\Exception $ex) {

jurgenhaas
committed
$fs = new Filesystem();
$fs->remove($path);
$fs->mkdir($path);
$repository->init();
$repository->addRemote('origin', $uri);
$repository->getCaller()->execute('branch --set-upstream-to origin/' . $version . ' ' . $version);