1
0
Fork 0

Fixed CS and unused variables

pull/104/head
Per Bernhardt 2011-11-10 13:10:05 +01:00
parent ee4d4ee3fa
commit 3e5fd85768
2 changed files with 24 additions and 23 deletions

View File

@ -19,6 +19,7 @@ use Composer\Package\PackageInterface;
*/ */
class HgDownloader implements DownloaderInterface class HgDownloader implements DownloaderInterface
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -50,8 +51,8 @@ class HgDownloader implements DownloaderInterface
throw new \InvalidArgumentException('The given package is missing reference information'); throw new \InvalidArgumentException('The given package is missing reference information');
} }
$this->enforceCleanDirectory($path); $this->enforceCleanDirectory($path);
system(sprintf('cd %s && hg pull && hg up %s', $path, $target->getSourceReference())); system(sprintf('cd %s && hg pull && hg up %s', $path, $target->getSourceReference()));
} }
/** /**

View File

@ -26,7 +26,7 @@ class HgDriver implements VcsDriverInterface
protected $infoCache = array(); protected $infoCache = array();
public function __construct($url) public function __construct($url)
{ {
$this->url = $url; $this->url = $url;
$this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/'; $this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/';
} }
@ -53,11 +53,11 @@ class HgDriver implements VcsDriverInterface
*/ */
public function getRootIdentifier() public function getRootIdentifier()
{ {
$tmpDir = escapeshellarg($this->tmpDir); $tmpDir = escapeshellarg($this->tmpDir);
if (null === $this->rootIdentifier) { if (null === $this->rootIdentifier) {
exec(sprintf('cd %s && hg tip --template "{rev}:{node|short}" --color never', $tmpDir), $output); exec(sprintf('cd %s && hg tip --template "{rev}:{node|short}" --color never', $tmpDir), $output);
$this->rootIdentifier = $output[0]; $this->rootIdentifier = $output[0];
} }
return $this->rootIdentifier; return $this->rootIdentifier;
} }
@ -74,7 +74,7 @@ class HgDriver implements VcsDriverInterface
*/ */
public function getSource($identifier) public function getSource($identifier)
{ {
$label = array_search($identifier, (array) $this->tags) ?: $identifier; $label = array_search($identifier, (array)$this->tags) ? : $identifier;
return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $label); return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $label);
} }
@ -98,7 +98,7 @@ class HgDriver implements VcsDriverInterface
unset($output); unset($output);
if (!$composer) { if (!$composer) {
throw new \UnexpectedValueException('Failed to retrieve composer information for identifier '.$identifier.' in '.$this->getUrl()); throw new \UnexpectedValueException('Failed to retrieve composer information for identifier ' . $identifier . ' in ' . $this->getUrl());
} }
$composer = JsonFile::parseJson($composer); $composer = JsonFile::parseJson($composer);
@ -111,7 +111,7 @@ class HgDriver implements VcsDriverInterface
$this->infoCache[$identifier] = $composer; $this->infoCache[$identifier] = $composer;
} }
return $this->infoCache[$identifier]; return $this->infoCache[$identifier];
} }
/** /**
@ -121,12 +121,12 @@ class HgDriver implements VcsDriverInterface
{ {
if (null === $this->tags) { if (null === $this->tags) {
exec(sprintf('cd %s && hg tags --color never', escapeshellarg($this->tmpDir)), $output); exec(sprintf('cd %s && hg tags --color never', escapeshellarg($this->tmpDir)), $output);
foreach ($output as $key => $tag) { foreach ($output as $tag) {
preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $tag, $match); preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $tag, $match);
$tags[$match[1]] = $match[2]; $tags[$match[1]] = $match[2];
} }
unset($tags['tip']); unset($tags['tip']);
$this->tags = $tags; $this->tags = $tags;
} }
return $this->tags; return $this->tags;
@ -141,9 +141,9 @@ class HgDriver implements VcsDriverInterface
$branches = array(); $branches = array();
exec(sprintf('cd %s && hg branches --color never', escapeshellarg($this->tmpDir)), $output); exec(sprintf('cd %s && hg branches --color never', escapeshellarg($this->tmpDir)), $output);
foreach ($output as $key => $branch) { foreach ($output as $branch) {
preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $branch, $match); preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $branch, $match);
$branches[$match[1]] = $match[2]; $branches[$match[1]] = $match[2];
} }
$this->branches = $branches; $this->branches = $branches;
@ -171,16 +171,16 @@ class HgDriver implements VcsDriverInterface
*/ */
public static function supports($url, $deep = false) public static function supports($url, $deep = false)
{ {
if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) { if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
return true; return true;
} }
if (!$deep) { if (!$deep) {
return false; return false;
} }
exec(sprintf('hg identify %s', escapeshellarg($url)), $output);
return (boolean) $output; exec(sprintf('hg identify %s', escapeshellarg($url)), $output);
return (boolean)$output;
} }
} }