Fixed issue 235, need consistent use of file and fullpath in the SCM backend

master
Loic d'Anterroches 2009-06-19 15:51:31 +02:00
parent b320375d60
commit a15107558c
4 changed files with 12 additions and 21 deletions

View File

@ -223,21 +223,6 @@ class IDF_Scm_Git extends IDF_Scm
return trim($out[0]); 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. * Get the tree info.
* *
@ -286,10 +271,11 @@ class IDF_Scm_Git extends IDF_Scm
foreach ($out as $line) { foreach ($out as $line) {
list($perm, $type, $hash, $size, $file) = preg_split('/ |\t/', $line, 5, PREG_SPLIT_NO_EMPTY); list($perm, $type, $hash, $size, $file) = preg_split('/ |\t/', $line, 5, PREG_SPLIT_NO_EMPTY);
if ($totest == $file) { if ($totest == $file) {
$pathinfo = pathinfo($file);
return (object) array('perm' => $perm, 'type' => $type, return (object) array('perm' => $perm, 'type' => $type,
'size' => $size, 'hash' => $hash, 'size' => $size, 'hash' => $hash,
'fullpath' => $file, 'fullpath' => $file,
'file' => $file); 'file' => $pathinfo['basename']);
} }
} }
return false; return false;

View File

@ -196,9 +196,11 @@ class IDF_Scm_Mercurial extends IDF_Scm
} }
$tmp .= $dir[$i]; $tmp .= $dir[$i];
if ($tmp == $totest) { if ($tmp == $totest) {
$pathinfo = pathinfo($totest);
return (object) array('perm' => '000', 'type' => 'tree', return (object) array('perm' => '000', 'type' => 'tree',
'hash' => $hash, 'hash' => $hash,
'file' => $totest, 'fullpath' => $totest,
'file' => $pathinfo['basename'],
'commit' => $commit 'commit' => $commit
); );
} }
@ -214,9 +216,11 @@ class IDF_Scm_Mercurial extends IDF_Scm
$type = 'blob'; $type = 'blob';
} }
if ($totest == $file) { if ($totest == $file) {
$pathinfo = pathinfo($totest);
return (object) array('perm' => $perm, 'type' => $type, return (object) array('perm' => $perm, 'type' => $type,
'hash' => $hash, 'hash' => $hash,
'file' => $file, 'fullpath' => $totest,
'file' => $pathinfo['basename'],
'commit' => $commit 'commit' => $commit
); );
} }

View File

@ -248,7 +248,8 @@ class IDF_Scm_Svn extends IDF_Scm
$file['fullpath'] = $filename; $file['fullpath'] = $filename;
$file['hash'] = (string) $entry->repository->uuid; $file['hash'] = (string) $entry->repository->uuid;
$file['type'] = $this->assoc[(string) $entry['kind']]; $file['type'] = $this->assoc[(string) $entry['kind']];
$file['file'] = $filename; $pathinfo = pathinfo($filename);
$file['file'] = $pathinfo['basename'];
$file['rev'] = $rev; $file['rev'] = $rev;
$file['author'] = (string) $entry->author; $file['author'] = (string) $entry->author;
$file['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $entry->commit->date)); $file['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $entry->commit->date));

View File

@ -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; $page_title = $bc.' - '.$title;
$cobject = $scm->getCommit($commit); $cobject = $scm->getCommit($commit);
@ -322,7 +322,7 @@ class IDF_Views_Source
$commit = $extra['commit']; $commit = $extra['commit'];
$request_file = $extra['request_file']; $request_file = $extra['request_file'];
$request_file_info = $extra['request_file_info']; $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; $page_title = $bc.' - '.$title;
$cobject = $scm->getCommit($commit); $cobject = $scm->getCommit($commit);
$in_branches = $scm->inBranches($commit, $request_file); $in_branches = $scm->inBranches($commit, $request_file);