1
0
Fork 0

Report errors properly when git driver fails to write in the cache, refs #482

pull/1205/head
Jordi Boggiano 2012-10-12 11:16:02 +02:00
parent 116b822953
commit 08670e7666
1 changed files with 7 additions and 1 deletions

View File

@ -38,6 +38,13 @@ class GitDriver extends VcsDriver
} else { } else {
$this->repoDir = $this->config->get('home') . '/cache.git/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/'; $this->repoDir = $this->config->get('home') . '/cache.git/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
$fs = new Filesystem();
$fs->ensureDirectoryExists(dirname($this->repoDir));
if (!is_writable(dirname($this->repoDir))) {
throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
}
// update the repo if it is a valid git repository // update the repo if it is a valid git repository
if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) { if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) {
if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) { if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) {
@ -45,7 +52,6 @@ class GitDriver extends VcsDriver
} }
} else { } else {
// clean up directory and do a fresh clone into it // clean up directory and do a fresh clone into it
$fs = new Filesystem();
$fs->removeDirectory($this->repoDir); $fs->removeDirectory($this->repoDir);
// added in git 1.7.1, prevents prompting the user // added in git 1.7.1, prevents prompting the user