diff --git a/src/IDF/Project.php b/src/IDF/Project.php index 005eff6..31bae65 100644 --- a/src/IDF/Project.php +++ b/src/IDF/Project.php @@ -362,6 +362,22 @@ class IDF_Project extends Pluf_Model $this); } + /** + * Get the remote write access url to the repository. + * + * Some SCM have a remote access URL to write which is not the + * same as the one to read. For example, you do a checkout with + * git-daemon and push with SSH. + */ + public function getWriteRemoteAccessUrl() + { + $conf = $this->getConf(); + $scm = $conf->getVal('scm', 'git'); + $scms = Pluf::f('allowed_scm'); + return call_user_func(array($scms[$scm], 'getWriteRemoteAccessUrl'), + $this); + } + /** * Get the root name of the project scm * diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index c512d4f..4ea1184 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -66,6 +66,17 @@ class IDF_Scm_Git return sprintf(Pluf::f('git_remote_url'), $project->shortname); } + /** + * Returns the URL for SSH access + * + * @param IDF_Project + * @return string URL + */ + public static function getWriteRemoteAccessUrl($project) + { + return sprintf(Pluf::f('git_write_remote_url'), $project->shortname); + } + /** * Returns this object correctly initialized for the project. * diff --git a/src/IDF/conf/idf.php-dist b/src/IDF/conf/idf.php-dist index 1d8479a..c9b3288 100644 --- a/src/IDF/conf/idf.php-dist +++ b/src/IDF/conf/idf.php-dist @@ -61,6 +61,7 @@ $cfg['git_repositories'] = '/home/git/repositories/%s.git'; # tree view. # $cfg['git_remote_url'] = 'git://localhost/%s.git'; +$cfg['git_write_remote_url'] = 'git@localhost:%s.git'; # Same as for git, you can have multiple repositories, one for each # project or a single one for all the projects. diff --git a/src/IDF/templates/idf/source/git/help.html b/src/IDF/templates/idf/source/git/help.html index 6c1f45e..582d095 100644 --- a/src/IDF/templates/idf/source/git/help.html +++ b/src/IDF/templates/idf/source/git/help.html @@ -22,7 +22,7 @@ code.{/blocktrans}

git init git add . git commit -m "initial import" -git remote add origin {$project.getRemoteAccessUrl()} +git remote add origin {$project.getWriteRemoteAccessUrl()} git push origin master