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"); } }
/** * @param int $project_id * @return Group */ public function transfer($project_id) { $data = $this->api('groups')->transfer($this->id, $project_id); return Group::fromArray($this->getClient(), $data); }
/** * @param int $group_id * @return bool */ public function removeFromGroup($group_id) { $group = new Group($group_id, $this->getClient()); return $group->removeMember($this->id); }
/** * @param int $group_id * @return Group */ public function transfer($group_id) { $group = new Group($group_id, $this->getClient()); return $group->transfer($this->id); }