From bb4fa7ca2f14748d28445e93738cc1a64dbd6722 Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Fri, 11 Mar 2011 11:38:04 +0100 Subject: [PATCH] Fix issue 629 : Git commit view is missing the branch --- src/IDF/Scm/Git.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index dc07e03..5c8d26e 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -167,7 +167,29 @@ class IDF_Scm_Git extends IDF_Scm */ public function inBranches($commit, $path) { - return $this->_inObject($commit, 'branch'); + if (isset($this->cache['inBranches'][$commit])) { + return $this->cache['inBranches'][$commit]; + } + + $cmd = Pluf::f('idf_exec_cmd_prefix', '') + .sprintf('GIT_DIR=%s %s branch --contains %s', + escapeshellarg($this->repo), + Pluf::f('git_path', 'git'), + escapeshellarg($commit)); + self::exec('IDF_Scm_Git::inBranches', $cmd, $out, $return); + if (0 != $return) { + throw new IDF_Scm_Exception(sprintf($this->error_tpl, + $cmd, $return, + implode("\n", $out))); + } + + $res = array(); + foreach ($out as $line) { + $res[] = substr($line, 2); + } + + $this->cache['inBranches'][$commit] = $res; + return $res; } /**