From a15107558c3d811a44ba550b3323d09e1120daea Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Fri, 19 Jun 2009 15:51:31 +0200 Subject: [PATCH] Fixed issue 235, need consistent use of file and fullpath in the SCM backend --- src/IDF/Scm/Git.php | 18 ++---------------- src/IDF/Scm/Mercurial.php | 8 ++++++-- src/IDF/Scm/Svn.php | 3 ++- src/IDF/Views/Source.php | 4 ++-- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index 35ab3f3..71a4714 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -223,21 +223,6 @@ class IDF_Scm_Git extends IDF_Scm return trim($out[0]); } - /** - * Given a commit hash returns an array of files in it. - * - * A file is a class with the following properties: - * - * 'perm', 'type', 'size', 'hash', 'file' - * - * @param string Commit ('HEAD') - * @param string Base folder ('') - * @return array - */ - public function filesAtCommit($commit='HEAD', $folder='') - { - } - /** * Get the tree info. * @@ -286,10 +271,11 @@ class IDF_Scm_Git extends IDF_Scm foreach ($out as $line) { list($perm, $type, $hash, $size, $file) = preg_split('/ |\t/', $line, 5, PREG_SPLIT_NO_EMPTY); if ($totest == $file) { + $pathinfo = pathinfo($file); return (object) array('perm' => $perm, 'type' => $type, 'size' => $size, 'hash' => $hash, 'fullpath' => $file, - 'file' => $file); + 'file' => $pathinfo['basename']); } } return false; diff --git a/src/IDF/Scm/Mercurial.php b/src/IDF/Scm/Mercurial.php index ea985de..5861e97 100644 --- a/src/IDF/Scm/Mercurial.php +++ b/src/IDF/Scm/Mercurial.php @@ -196,9 +196,11 @@ class IDF_Scm_Mercurial extends IDF_Scm } $tmp .= $dir[$i]; if ($tmp == $totest) { + $pathinfo = pathinfo($totest); return (object) array('perm' => '000', 'type' => 'tree', 'hash' => $hash, - 'file' => $totest, + 'fullpath' => $totest, + 'file' => $pathinfo['basename'], 'commit' => $commit ); } @@ -214,9 +216,11 @@ class IDF_Scm_Mercurial extends IDF_Scm $type = 'blob'; } if ($totest == $file) { + $pathinfo = pathinfo($totest); return (object) array('perm' => $perm, 'type' => $type, 'hash' => $hash, - 'file' => $file, + 'fullpath' => $totest, + 'file' => $pathinfo['basename'], 'commit' => $commit ); } diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php index e73f4de..c9e1737 100644 --- a/src/IDF/Scm/Svn.php +++ b/src/IDF/Scm/Svn.php @@ -248,7 +248,8 @@ class IDF_Scm_Svn extends IDF_Scm $file['fullpath'] = $filename; $file['hash'] = (string) $entry->repository->uuid; $file['type'] = $this->assoc[(string) $entry['kind']]; - $file['file'] = $filename; + $pathinfo = pathinfo($filename); + $file['file'] = $pathinfo['basename']; $file['rev'] = $rev; $file['author'] = (string) $entry->author; $file['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $entry->commit->date)); diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index 5d6978b..3753ed8 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -201,7 +201,7 @@ class IDF_Views_Source } } - $bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->file); + $bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->fullpath); $page_title = $bc.' - '.$title; $cobject = $scm->getCommit($commit); @@ -322,7 +322,7 @@ class IDF_Views_Source $commit = $extra['commit']; $request_file = $extra['request_file']; $request_file_info = $extra['request_file_info']; - $bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->file); + $bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->fullpath); $page_title = $bc.' - '.$title; $cobject = $scm->getCommit($commit); $in_branches = $scm->inBranches($commit, $request_file);