Skip to content
Snippets Groups Projects
Commit 79c4b8b6 authored by jurgenhaas's avatar jurgenhaas
Browse files

Initial code

parent ca395eab
No related branches found
Tags v0.1.0
No related merge requests found
......@@ -7,6 +7,7 @@ use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Script\Event as ScriptEvent;
use GitElephant\Repository;
use Symfony\Component\Filesystem\Filesystem;
class Handler {
......@@ -88,11 +89,33 @@ class Handler {
*/
protected function prepareWorkingDirectory($path, $project, $version, $username) {
list(, $projectname) = explode('/', $project);
$repo = $username . '@git.drupal.org:project/' . $projectname . '.git';
$uri = $username . '@git.drupal.org:project/' . $projectname . '.git';
// Git Clone the repository into the working directory
$repository = Repository::open($path);
$repository->cloneFrom($repo, '.');
$repository->init();
$originExists = FALSE;
/** @var \GitElephant\Objects\Remote $remote */
foreach ($repository->getRemotes() as $remote) {
if ($remote->getName() == 'origin') {
if ($remote->getFetchURL() != $uri) {
$remote->setFetchURL($uri);
}
$originExists = TRUE;
break;
}
}
if (!$originExists) {
$fs = new Filesystem();
$fs->remove($path);
$fs->mkdir($path);
$repository->init();
$repository->addRemote('origin', $uri);
}
$repository->fetch();
$repository->checkout($version);
}
......
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