Restructured the file hierarchy.

Git and Svn are now in a Scm subfolder.
This commit is contained in:
Loic d'Anterroches 2008-09-01 21:42:18 +02:00
parent fad12e17c7
commit 57a5b4738a
5 changed files with 16 additions and 16 deletions

View File

@ -24,7 +24,7 @@
/**
* Manage differents SCM systems
*/
class IDF_ScmFactory
class IDF_Scm
{
/**
@ -32,17 +32,17 @@ class IDF_ScmFactory
*
* @return Object
*/
public static function getScm($request=null)
public static function get($request=null)
{
// Get scm type from project conf ; defaults to git
switch ($request->conf->getVal('scm', 'git')) {
case 'svn':
return new IDF_Svn($request->conf->getVal('svn_repository'),
return new IDF_Scm_Svn($request->conf->getVal('svn_repository'),
$request->conf->getVal('svn_username'),
$request->conf->getVal('svn_password'));
case 'git':
default:
return new IDF_Git($request->project->getGitRepository());
return new IDF_Scm_Git($request->project->getGitRepository());
}
}
}

View File

@ -25,7 +25,7 @@
* Git utils.
*
*/
class IDF_Git
class IDF_Scm_Git
{
public $repo = '';
public $mediumtree_fmt = 'commit %H%nAuthor: %an <%ae>%nTree: %T%nDate: %ai%n%n%s%n%n%b';

View File

@ -25,7 +25,7 @@
* SVN utils.
*
*/
class IDF_Svn
class IDF_Scm_Svn
{
public $repo = '';
public $username = '';

View File

@ -30,13 +30,13 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag
{
private $project = null;
private $request = null;
private $git = null;
private $scm = null;
function start($text, $request)
{
$this->project = $request->project;
$this->request = $request;
$this->git = new IDF_Git($this->project->getGitRepository());
$this->scm = IDF_Scm::get($request);
$text = wordwrap($text, 69, "\n", true);
$text = Pluf_esc($text);
$text = ereg_replace('[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]',
@ -47,7 +47,7 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag
array($this, 'callbackIssues'), $text);
}
if ($request->rights['hasSourceAccess']) {
$text = preg_replace_callback('#(commit\s+)([0-9a-f]{5,40})#im',
$text = preg_replace_callback('#(commit\s+)([0-9a-f]{1,40})#im',
array($this, 'callbackCommit'), $text);
}
echo $text;
@ -90,10 +90,10 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag
function callbackCommit($m)
{
if ($this->git->testHash($m[2]) != 'commit') {
if ($this->scm->testHash($m[2]) != 'commit') {
return $m[0];
}
$co = $this->git->getCommit($m[2]);
$co = $this->scm->getCommit($m[2]);
return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Source::commit', array($this->project->shortname, $co->commit)).'">'.$m[1].$m[2].'</a>';
}

View File

@ -36,7 +36,7 @@ class IDF_Views_Source
{
$title = sprintf(__('%s %s Change Log'), (string) $request->project,
$this->getScmType($request));
$scm = IDF_ScmFactory::getScm($request);
$scm = IDF_Scm::get($request);
$branches = $scm->getBranches();
$commit = $match[2];
$res = $scm->getChangeLog($commit, 25);
@ -58,7 +58,7 @@ class IDF_Views_Source
{
$title = sprintf(__('%s %s Source Tree'), (string) $request->project,
$this->getScmType($request));
$scm = IDF_ScmFactory::getScm($request);
$scm = IDF_Scm::get($request);
$commit = $match[2];
$branches = $scm->getBranches();
if ('commit' != $scm->testHash($commit)) {
@ -96,7 +96,7 @@ class IDF_Views_Source
{
$title = sprintf(__('%s %s Source Tree'), (string) $request->project,
$this->getScmType($request));
$scm = IDF_ScmFactory::getScm($request);
$scm = IDF_Scm::get($request);
$branches = $scm->getBranches();
$commit = $match[2];
$request_file = $match[3];
@ -179,7 +179,7 @@ class IDF_Views_Source
public $commit_precond = array('IDF_Precondition::accessSource');
public function commit($request, $match)
{
$scm = IDF_ScmFactory::getScm($request);
$scm = IDF_Scm::get($request);
$commit = $match[2];
$branches = $scm->getBranches();
if ('commit' != $scm->testHash($commit)) {
@ -216,7 +216,7 @@ class IDF_Views_Source
public function download($request, $match)
{
$commit = trim($match[2]);
$scm = IDF_ScmFactory::getScm($request);
$scm = IDF_Scm::get($request);
$branches = $scm->getBranches();
if ('commit' != $scm->testHash($commit)) {
// Redirect to the first branch