Skip to content
Snippets Groups Projects
Commit 96716d8e authored by jurgenhaas's avatar jurgenhaas
Browse files

#4 Quickly get just the origin remote and skip further steps if the uri already matches

parent 9f3fc112
No related branches found
No related tags found
No related merge requests found
......@@ -58,8 +58,12 @@ class Handler {
}
$options = $this->getOptions();
$installationManager = $this->composer->getInstallationManager();
if (empty($options['projects'])) {
return;
}
$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);
if (empty($package)) {
......@@ -67,6 +71,7 @@ class Handler {
}
$path = $installationManager->getInstallPath($package);
$this->io->write("- $project => $path", TRUE);
$this->prepareWorkingDirectory($path, $project, $version, $options['username']);
}
}
......@@ -97,31 +102,27 @@ class Handler {
$repository = Repository::open($path);
$repository->init();
$originExists = FALSE;
/** @var \GitElephant\Objects\Remote $remote */
foreach ($repository->getRemotes() as $remote) {
if ($remote->getName() == 'origin') {
if ($remote->getFetchURL() != $uri) {
$repository->getCaller()->execute('remote remove origin');
}
else {
$originExists = TRUE;
}
break;
try {
$origin = $repository->getRemote('origin', FALSE);
if ($origin && $origin->getFetchURL() == $uri) {
// Already setup correctly.
return;
}
}
if (!$originExists) {
$fs = new Filesystem();
$fs->remove($path);
$fs->mkdir($path);
$repository->init();
$repository->addRemote('origin', $uri);
catch (\Exception $ex) {
// ignore the exception and conitue setup.
}
$fs = new Filesystem();
$fs->remove($path);
$fs->mkdir($path);
$repository->init();
$repository->addRemote('origin', $uri);
$repository->fetch();
$repository->checkout($version);
$repository->getCaller()->execute('branch --set-upstream-to origin/' . $version . ' ' . $version);
$this->io->write(" - completed", TRUE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment