protected function getProjectChoices(\VersionControl\GitlabIssueBundle\Entity\ProjectIssueIntegratorGitlab $projectIssueIntegrator) { $client = new \Gitlab\Client(rtrim($projectIssueIntegrator->getUrl(), '/') . '/api/v3/'); // change here $client->authenticate($projectIssueIntegrator->getApiToken(), \Gitlab\Client::AUTH_URL_TOKEN); $choices = array(); $dataResponse = $client->api('projects')->all(1, 200); $gitlabProjectToEntityTransformer = new GitlabProjectToEntityTransformer(); foreach ($dataResponse as $gitLabProject) { $choices[] = $gitlabProjectToEntityTransformer->transform($gitLabProject); } return $choices; }
protected function execute(InputInterface $input, OutputInterface $output) { $header_style = new OutputFormatterStyle('black', 'white', array('bold')); $output->getFormatter()->setStyle('header', $header_style); $path = $input->getOption("path"); if (empty($path)) { throw new \InvalidArgumentException('Gitlab path not specified'); } $groupName = $input->getOption("group"); if (empty($groupName)) { throw new \InvalidArgumentException('Gitlab group not specified'); } $token = $input->getOption("token"); if (empty($token)) { throw new \InvalidArgumentException('Gitlab token not specified'); } $client = new \Gitlab\Client('http://' . $path . '/api/v3/'); $client->authenticate($token, \Gitlab\Client::AUTH_URL_TOKEN); $groupsApi = $client->api("groups"); $foundGroups = $groupsApi->search($groupName, 1, 1000); if (count($foundGroups) > 0) { foreach ($foundGroups as $groupData) { $groupId = $groupData["id"]; $group = \Gitlab\Model\Group::fromArray($client, $groupsApi->show($groupId)); $output->writeln('<header>Clone repositories from Group "' . $group->name . '" ...</header>'); foreach ($group->projects as $project) { $cloningPath = $project->ssh_url_to_repo; //clone repo $cloneCommand = 'git clone ' . $cloningPath; $output->writeln(' ' . $cloneCommand); $process = new Process('git clone ' . $cloningPath); $process->setTimeout(3600); $process->run(function ($type, $buffer) { global $output; echo ' ' . $buffer; }); } } } else { throw new \ErrorException("No group containing: " . $groupName . " found"); } }