/** * validate git-remote add [options] <name> <url> */ public function testAdd() { $name = 'foobar'; $url = 'git@foobar.com:/Foo/Bar.git'; $options = array('-t bazblurg', '--mirror=fetch', '--tags'); $actual = RemoteCommand::getInstance()->add($name, $url, $options); $expected = "remote add '-t' 'bazblurg' '--mirror=fetch' '--tags' '{$name}' '{$url}'"; $this->assertEquals($expected, $actual, 'add() builds remote command with add subcommand'); }
/** * get output lines from git-remote show [name] * * NOTE: for technical reasons $name is optional, however under normal * implementation it SHOULD be passed! * * @param string $name Name of remote to show details * @param RemoteCommand $remoteCmd Optionally provide RemoteCommand object * @param bool $queryRemotes Do not fetch new information from remotes * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException * @throws \Symfony\Component\Process\Exception\InvalidArgumentException * @throws \Symfony\Component\Process\Exception\RuntimeException * @return array */ public function getShowOutput($name = null, RemoteCommand $remoteCmd = null, $queryRemotes = true) { if (!$remoteCmd) { $remoteCmd = RemoteCommand::getInstance($this->repository); } $command = $remoteCmd->show($name, $queryRemotes); return $this->repository->getCaller()->execute($command)->getOutputLines(true); }
/** * gets a list of remote objects * * @param bool $queryRemotes Fetch new information from remotes * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException * @throws \Symfony\Component\Process\Exception\InvalidArgumentException * @throws \Symfony\Component\Process\Exception\RuntimeException * @return array */ public function getRemotes($queryRemotes = true) { $remoteNames = $this->caller->execute(RemoteCommand::getInstance($this)->show(null, $queryRemotes))->getOutputLines(true); $remotes = array(); foreach ($remoteNames as $remoteName) { $remotes[] = $this->getRemote($remoteName, $queryRemotes); } return $remotes; }