From: Chuck Hagenbuch Date: Sat, 13 Jun 2009 03:35:31 +0000 (-0400) Subject: - throw an error up front if the git binary isn't found X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d535f522e6b94c8426e33e224858a4978e3781a6;p=horde.git - throw an error up front if the git binary isn't found - add .git or /.git to the sourceroot path if it doesn't look right --- diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index 9788d97af..047bc318a 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -65,8 +65,22 @@ class Horde_Vcs_Git extends Horde_Vcs { parent::__construct($params); + if (!is_executable($this->getPath('git'))) { + throw new Horde_Vcs_Exception('Missing git binary (' . $this->getPath('git') . ' is missing or not executable)'); + } + $v = trim(shell_exec($this->getPath('git') . ' --version')); $this->version = preg_replace('/[^\d\.]/', '', $v); + + // Try to find the repository if we don't have the exact path. @TODO put + // this into a builder method/object and cache the results. + if (!file_exists($this->sourceroot() . '/HEAD')) { + if (file_exists($this->sourceroot() . '.git/HEAD')) { + $this->_sourceroot .= '.git'; + } elseif (file_exists($this->sourceroot() . '/.git/HEAD')) { + $this->_sourceroot .= '/.git'; + } + } } /**