2 /** FusionForge Git plugin
4 * Copyright 2009, Roland Mas
6 * This file is part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License,
11 * or (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with FusionForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 class GitPlugin extends SCMPlugin {
25 function GitPlugin () {
28 $this->name = 'scmgit';
30 $this->hooks[] = 'scm_generate_snapshots' ;
32 require_once $gfconfig.'plugins/scmgit/config.php' ;
34 $this->default_git_server = $default_git_server ;
35 $this->git_root = $git_root;
40 function getDefaultServer() {
41 return $this->default_git_server ;
44 function getBlurb () {
45 return _('<p>This GIT plugin is not completed yet.</p>') ;
48 function getInstructionsForAnon ($project) {
49 $b = _('<p><b>Anonymous GIT Access</b></p><p>This project\'s GIT repository cannot be anonymously checked out yet.</p>');
53 function getInstructionsForRW ($project) {
54 $b = _('<p><b>Developer GIT Access via SSH</b></p><p>Only project developers can access the GIT tree via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.</p>');
55 $b .= '<p><tt>git clone git+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . ':'. $this->git_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
59 function getSnapshotPara ($project) {
63 function getBrowserLinkBlock ($project) {
67 function getStatsBlock ($project) {
71 function createOrUpdateRepo ($params) {
72 $project = $this->checkParams ($params) ;
77 if (! $project->usesPlugin ($this->name)) {
81 $repo = $this->git_root . '/' . $project->getUnixName() ;
82 $unix_group = 'scm_' . $project->getUnixName() ;
84 system ("mkdir -p $repo") ;
85 if (!is_dir ("$repo/.git")) {
86 system ("git init $repo") ;
89 system ("chgrp -R $unix_group $repo") ;
90 if ($project->enableAnonSCM()) {
91 system ("chmod -R g+wXs,o+rX-w $repo") ;
93 system ("chmod -R g+wXs,o-rwx $repo") ;
97 function generateSnapshots ($params) {
98 global $sys_scm_tarballs_path ;
100 $project = $this->checkParams ($params) ;
105 $group_name = $project->getUnixName() ;
107 $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
109 if (! $project->usesPlugin ($this->name)) {
113 if (! $project->enableAnonSCM()) {
118 $toprepo = $this->git_root ;
119 $repo = $toprepo . '/' . $project->getUnixName() ;
121 if (!is_dir ($repo)) {
126 $tmp = trim (`mktemp -d`) ;
130 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
131 chmod ("$tmp/tarball.tar.gz", 0644) ;
132 copy ("$tmp/tarball.tar.gz", $tarball) ;
133 unlink ("$tmp/tarball.tar.gz") ;
134 system ("rm -rf $tmp") ;
140 // c-file-style: "bsd"