From 57a5b4738aeecf95080838f3baf2e69da9a5d77b Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Mon, 1 Sep 2008 21:42:18 +0200 Subject: [PATCH] Restructured the file hierarchy. Git and Svn are now in a Scm subfolder. --- src/IDF/{ScmFactory.php => Scm.php} | 8 ++++---- src/IDF/{ => Scm}/Git.php | 2 +- src/IDF/{ => Scm}/Svn.php | 2 +- src/IDF/Template/IssueComment.php | 10 +++++----- src/IDF/Views/Source.php | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) rename src/IDF/{ScmFactory.php => Scm.php} (87%) rename src/IDF/{ => Scm}/Git.php (99%) rename src/IDF/{ => Scm}/Svn.php (99%) diff --git a/src/IDF/ScmFactory.php b/src/IDF/Scm.php similarity index 87% rename from src/IDF/ScmFactory.php rename to src/IDF/Scm.php index d2d8a7f..5889579 100644 --- a/src/IDF/ScmFactory.php +++ b/src/IDF/Scm.php @@ -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()); } } } diff --git a/src/IDF/Git.php b/src/IDF/Scm/Git.php similarity index 99% rename from src/IDF/Git.php rename to src/IDF/Scm/Git.php index 316f928..09fb0f9 100644 --- a/src/IDF/Git.php +++ b/src/IDF/Scm/Git.php @@ -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'; diff --git a/src/IDF/Svn.php b/src/IDF/Scm/Svn.php similarity index 99% rename from src/IDF/Svn.php rename to src/IDF/Scm/Svn.php index fc3f4c0..e094d88 100644 --- a/src/IDF/Svn.php +++ b/src/IDF/Scm/Svn.php @@ -25,7 +25,7 @@ * SVN utils. * */ -class IDF_Svn +class IDF_Scm_Svn { public $repo = ''; public $username = ''; diff --git a/src/IDF/Template/IssueComment.php b/src/IDF/Template/IssueComment.php index 9023801..1b7d957 100644 --- a/src/IDF/Template/IssueComment.php +++ b/src/IDF/Template/IssueComment.php @@ -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 ''.$m[1].$m[2].''; } diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index ff79309..ae07c1e 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -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