public function parse() { $hp = new HtmlParser(); $ret = $hp->extractGitUrls($this->url); $this->arGitUrls = $hp->getGitUrls(); $this->error = $hp->error; return $ret; }
/** * Stores the linkback as remote fork in the paste repository. * * @param string $target Target URI that should be linked in $source * @param string $source Linkback source URI that should link to target * @param string $sourceBody Content of $source URI * @param object $res HTTP response from fetching $source * * @return void * * @throws SPb\Exception When storing the linkback fatally failed */ public function storeLinkback($target, $source, $sourceBody, \HTTP_Request2_Response $res) { //FIXME: deleted //FIXME: cleanuptask $hp = new HtmlParser(); $ok = $hp->extractGitUrls($source, $sourceBody); if ($ok === false) { //failed to extract git URL from linkback source //FIXME: send exception //$hp->error return; } $ci = $this->repo->getConnectionInfo(); $forks = $ci->getForks(); $arRemoteCloneUrls = $this->localizeGitUrls($hp->getGitUrls()); $remoteCloneUrl = $remoteTitle = null; if (count($arRemoteCloneUrls)) { reset($arRemoteCloneUrls); list($remoteCloneUrl, $remoteTitle) = each($arRemoteCloneUrls); } $remoteid = 'fork-' . uniqid(); //check if we already know this remote foreach ($forks as $remote) { if (isset($arRemoteCloneUrls[$remote->getCloneUrl()])) { $remoteTitle = $arRemoteCloneUrls[$remote->getCloneUrl()]; $remoteid = $remote->getName(); break; } else { if ($source == $remote->getWebURL(true)) { $remoteid = $remote->getName(); break; } } } $vc = $this->repo->getVc(); if (!$this->isLocalWebUrl($source)) { //only add remote homepage; we can calculate local ones ourselves $vc->getCommand('config')->addArgument('remote.' . $remoteid . '.homepage')->addArgument($source)->execute(); } if ($remoteTitle !== null) { $vc->getCommand('config')->addArgument('remote.' . $remoteid . '.title')->addArgument($remoteTitle)->execute(); } if ($remoteCloneUrl !== null) { $vc->getCommand('config')->addArgument('remote.' . $remoteid . '.url')->addArgument($remoteCloneUrl)->execute(); } }