From 39d015a586c4cb35b9c393a126ba295a6533080c Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Mon, 24 Nov 2008 20:27:03 +0100 Subject: [PATCH] Added a simpler way to configure the repositories. --- src/IDF/Scm/Git.php | 11 ++------ src/IDF/Scm/Mercurial.php | 11 ++------ src/IDF/Scm/Svn.php | 11 ++------ src/IDF/conf/idf.php-dist | 57 ++++++++++++++++++--------------------- 4 files changed, 32 insertions(+), 58 deletions(-) diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index 19469b0..338cc15 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -43,11 +43,7 @@ class IDF_Scm_Git */ public static function getRemoteAccessUrl($project) { - $url = Pluf::f('git_remote_url'); - if (Pluf::f('git_repositories_unique', true)) { - return $url; - } - return $url.'/'.$project->shortname.'.git'; + return sprintf(Pluf::f('git_remote_url'), $project->shortname); } /** @@ -58,10 +54,7 @@ class IDF_Scm_Git */ public static function factory($project) { - $rep = Pluf::f('git_repositories'); - if (false == Pluf::f('git_repositories_unique', false)) { - $rep = $rep.'/'.$project->shortname.'.git'; - } + $rep = sprintf(Pluf::f('git_repositories'), $project->shortname); return new IDF_Scm_Git($rep); } diff --git a/src/IDF/Scm/Mercurial.php b/src/IDF/Scm/Mercurial.php index d90dd99..5d3fea3 100644 --- a/src/IDF/Scm/Mercurial.php +++ b/src/IDF/Scm/Mercurial.php @@ -42,11 +42,7 @@ class IDF_Scm_Mercurial */ public static function getRemoteAccessUrl($project) { - $url = Pluf::f('mercurial_remote_url'); - if (Pluf::f('mercurial_repositories_unique', true)) { - return $url; - } - return $url.'/'.$project->shortname; + return sprintf(Pluf::f('mercurial_remote_url'), $project->shortname); } /** @@ -57,10 +53,7 @@ class IDF_Scm_Mercurial */ public static function factory($project) { - $rep = Pluf::f('mercurial_repositories'); - if (false == Pluf::f('mercurial_repositories_unique', false)) { - $rep = $rep.'/'.$project->shortname; - } + $rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname); return new IDF_Scm_Mercurial($rep); } diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php index cfbed75..d934e4d 100644 --- a/src/IDF/Scm/Svn.php +++ b/src/IDF/Scm/Svn.php @@ -55,11 +55,7 @@ class IDF_Scm_Svn // Remote repository return $url; } - $url = Pluf::f('svn_remote_url'); - if (Pluf::f('svn_repositories_unique', true)) { - return $url; - } - return $url.'/'.$project->shortname; + return sprintf(Pluf::f('svn_remote_url'), $project->shortname); } /** @@ -79,10 +75,7 @@ class IDF_Scm_Svn $conf->getVal('svn_username'), $conf->getVal('svn_password')); } else { - $rep = Pluf::f('svn_repositories'); - if (false == Pluf::f('svn_repositories_unique', false)) { - $rep = $rep.'/'.$project->shortname; - } + $rep = sprintf(Pluf::f('svn_repositories'), $project->shortname); return new IDF_Scm_Svn($rep); } } diff --git a/src/IDF/conf/idf.php-dist b/src/IDF/conf/idf.php-dist index ab15567..78ad9cb 100644 --- a/src/IDF/conf/idf.php-dist +++ b/src/IDF/conf/idf.php-dist @@ -26,21 +26,27 @@ $cfg = array(); // to start with, it can be practical. $cfg['debug'] = false; -// if you have a single git repository, just put the full path to it -// without trailing slash. -// If within a folder you have a series of bare git repository, just -// put the folder without a trailing slash. -// InDefero will automatically append a slash, the project shortname -// and .git to create the name of the repository. -$cfg['git_repositories'] = '/home/git/repositories/indefero.git'; -$cfg['git_repositories_unique'] = true; -$cfg['git_remote_url'] = 'git://projects.ceondo.com/indefero.git'; - -// One git repository per project. "/".$project->shortname.".git" -// is automatically added to the end of the path/url. -//$cfg['git_repositories'] = '/home/git/repositories'; -//$cfg['git_repositories_unique'] = false; -//$cfg['git_remote_url'] = 'git://projects.ceondo.com'; +// If you have a single git repository, just put the full path to it +// without trailing slash. The path is the path to the git database, +// so you need to include the /.git folder. +// For example: '/path/to/my/project/.git' +// +// If you have multiple repositories, you need to put %s where you +// want the shortname of the project to be replaced. +// For example: +// - You have many projects on your local computer and want to use +// InDefero to see them. Put: '/home/yourlogin/Projects/%s/.git' +// - You have many projects on a remote server with only "bare" git +// repositories. Put: '/home/git/repositories/%s.git' +// +$cfg['git_repositories'] = '/home/git/repositories/%s.git'; +// +// Like for the git_repositories definition, the path can contains %s +// and it will be automatically replaced. You can ignore this +// configuration variable as it is only for information use in the +// tree view. +// +$cfg['git_remote_url'] = 'git://projects.ceondo.com/%s.git'; // Same as for git, you can have multiple repositories, one for each // project or a single one for all the projects. @@ -49,24 +55,12 @@ $cfg['git_remote_url'] = 'git://projects.ceondo.com/indefero.git'; // remote repository from the web interface. From the web interface // you can define a local repository, local repositories are defined // here. This if for security reasons. -$cfg['svn_repositories'] = 'file:///home/svn/repositories/indefero'; -$cfg['svn_repositories_unique'] = true; -$cfg['svn_remote_url'] = 'http://projects.ceondo.com/svn/indefero'; +$cfg['svn_repositories'] = 'file:///home/svn/repositories/%s'; +$cfg['svn_remote_url'] = 'http://projects.ceondo.com/svn/%s'; // Mercurial repositories path -//$cfg['mercurial_repositories'] = '/home/mercurial/repositories'; -//$cfg['mercurial_repositories_unique'] = false; -//$cfg['mercurial_remote_url'] = 'http://projects.ceondo.com/hg'; - -// Example of one *local* subversion repository for each project: - -// the path to the repository on disk will automatically created to be -// 'file:///home/svn/repositories'.'/'.$project->shortname -// the url will be generated the same way: -// 'http://projects.ceondo.com/svn'.'/'.$project->shortname -// $cfg['svn_repositories'] = 'file:///home/svn/repositories'; -// $cfg['svn_repositories_unique'] = false; -// $cfg['svn_remote_url'] = 'http://projects.ceondo.com/svn'; +//$cfg['mercurial_repositories'] = '/home/mercurial/repositories/%s'; +//$cfg['mercurial_remote_url'] = 'http://projects.ceondo.com/hg/%s'; // admins will get an email in case of errors in the system in non // debug mode. @@ -178,6 +172,7 @@ $cfg['languages'] = array('en', 'fr'); # SCM base configuration $cfg['allowed_scm'] = array('git' => 'IDF_Scm_Git', 'svn' => 'IDF_Scm_Svn', + 'mercurial' => 'IDF_Scm_Mercurial', );