<?php
-/** FusionForge Git plugin
+/**
+ * FusionForge Git plugin
*
* Copyright 2009, Roland Mas
* Copyright 2009, Mehdi Dogguy <mehdi@debian.org>
+ * Copyright 2012, Franck Villaume - TrivialDev
+ * http://fusionforge.org
*
* This file is part of FusionForge.
*
if ($rows > 0) {
$b .= '<h2>';
$b .= _('Developer\'s repository');
- $b .= '</h2>';
+ $b .= '</h2>'."\n";
$b .= '<p>';
$b .= ngettext('One of this project\'s members also has a personal Git repository that can be checked out anonymously.',
'Some of this project\'s members also have personal Git repositories that can be checked out anonymously.',
function getInstructionsForRW($project) {
if (session_loggedin()) {
- $u =& user_get_object(user_getid());
+ $u = user_get_object(user_getid());
$d = $u->getUnixName();
if (forge_get_config('use_ssh', 'scmgit')) {
$b = '<h2>';
- $b .= _('Developer GIT Access via SSH');
+ $b .= _('Developer Git Access via SSH');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the GIT tree via this method. SSH must be installed on your client machine. Enter your site password when prompted.');
+ $b .= _('Only project developers can access the Git tree via this method. SSH must be installed on your client machine. Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>git clone git+ssh://'.$d.'@' . $this->getBoxForProject($project) . '/'. forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/'. $project->getUnixName() .'.git</tt></p>' ;
} elseif (forge_get_config('use_dav', 'scmgit')) {
$protocol = forge_get_config('use_ssl', 'scmgit')? 'https' : 'http';
$b = '<h2>';
- $b .= _('Developer GIT Access via HTTP');
+ $b .= _('Developer Git Access via HTTP');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the GIT tree via this method. Enter your site password when prompted.');
+ $b .= _('Only project developers can access the Git tree via this method. Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>git clone '.$protocol.'://'.$d.'@' . $this->getBoxForProject($project) . '/'. forge_get_config('scm_root', 'scmgit') .'/'. $project->getUnixName() .'/'. $project->getUnixName() .'.git</tt></p>' ;
} else {
} else {
if (forge_get_config('use_ssh', 'scmgit')) {
$b = '<h2>';
- $b .= _('Developer GIT Access via SSH');
+ $b .= _('Developer Git Access via SSH');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('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 value. Enter your site password when prompted.');
+ $b .= _('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 value. Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>git clone git+ssh://<i>'._('developername').'</i>@' . $this->getBoxForProject($project) . '/'. forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/'. $project->getUnixName() .'.git</tt></p>' ;
} elseif (forge_get_config('use_dav', 'scmgit')) {
$protocol = forge_get_config('use_ssl', 'scmgit')? 'https' : 'http';
$b = '<h2>';
- $b .= _('Developer GIT Access via HTTP');
+ $b .= _('Developer Git Access via HTTP');
$b .= '</h2>';
$b .= '<p>';
- $b .= _('Only project developers can access the GIT tree via this method. Enter your site password when prompted.');
+ $b .= _('Only project developers can access the Git tree via this method. Enter your site password when prompted.');
$b .= '</p>';
$b .= '<p><tt>git clone '.$protocol.'://<i>'._('developername').'</i>@' . $this->getBoxForProject($project) . '/'. forge_get_config('scm_root', 'scmgit') .'/'. $project->getUnixName() .'/'. $project->getUnixName() .'.git</tt></p>' ;
}
$b .= '<p>';
$b .= _('You have a personal repository for this project, accessible through SSH with the following method. Enter your site password when prompted.');
$b .= '</p>';
- $b .= '<p><tt>git clone git+ssh://'.$u->getUnixName().'@' . $this->getBoxForProject($project) . forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/users/'. $u->getUnixName() .'.git</tt></p>' ;
+ $b .= '<p><tt>git clone git+ssh://'.$u->getUnixName().'@' . $this->getBoxForProject($project) . '/'. forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/users/'. $u->getUnixName() .'.git</tt></p>' ;
} else {
$glist = $u->getGroups();
foreach ($glist as $g) {
}
function printBrowserPage($params) {
- global $HTML;
-
$project = $this->checkParams($params);
if (!$project) {
return false;
$project_name = $project->getUnixName();
$root = forge_get_config('repos_path', 'scmgit') . '/' . $project_name ;
system ("mkdir -p $root");
+ $output = '';
$main_repo = $root . '/' . $project_name . '.git' ;
if (!is_file ("$main_repo/HEAD") && !is_dir("$main_repo/objects") && !is_dir("$main_repo/refs")) {
}
$config_dir = forge_get_config('config_path').'/plugins/scmgit';
+ if (!is_dir($config_dir)) {
+ mkdir($config_dir, 0755, true);
+ }
$fname = $config_dir . '/gitweb.conf' ;
$config_f = fopen($fname.'.new', 'w') ;
$rootdir = forge_get_config('repos_path', 'scmgit');
function getRepositories($path) {
if (! is_dir($path)) {
- echo 'pas de path ?';
- return;
+ return array();
}
$list = array();
$entries = scandir($path);
}
function gatherStats ($params) {
- global $last_user, $usr_adds, $usr_deletes,
- $usr_updates, $updates, $adds;
-
$project = $this->checkParams ($params) ;
if (!$project) {
return false ;
}
if ($params['mode'] == 'day') {
- db_begin();
-
$year = $params ['year'] ;
$month = $params ['month'] ;
$day = $params ['day'] ;
$repo = forge_get_config('repos_path', 'scmgit') . '/' . $project->getUnixName() . '/' . $project->getUnixName() . '.git';
if (!is_dir ($repo) || !is_dir ("$repo/refs")) {
// echo "No repository\n" ;
- db_rollback () ;
return false ;
}
- $pipe = popen ("GIT_DIR=\"$repo\" git log --since=@$start_time --until=@$end_time --all --pretty='format:%n%an <%ae>' --name-status", 'r' ) ;
+ $pipe = popen ("GIT_DIR=\"$repo\" git log --since=@$start_time --until=@$end_time --all --pretty='format:%n%an <%ae>' --name-status 2>/dev/null", 'r' ) ;
+
+ db_begin();
// cleaning stats_cvs_* table for the current day
$res = db_query_params ('DELETE FROM stats_cvs_group WHERE month=$1 AND day=$2 AND group_id=$3',
while (!feof($pipe) && $data = fgets ($pipe)) {
$line = trim($data);
if (strlen($line) > 0) {
- $result = preg_match("/^(?<name>.+) <(?<mail>.+)>/", $line, $matches);
+ $result = preg_match("/^(?P<name>.+) <(?P<mail>.+)>/", $line, $matches);
if ($result) {
// Author line
$last_user = $matches['name'];
$user2email[$last_user] = strtolower($matches['mail']);
} else {
// Short-commit stats line
- preg_match("/^(?<mode>[AM])\s+(?<file>.+)$/", $line, $matches);
+ preg_match("/^(?P<mode>[AM])\s+(?P<file>.+)$/", $line, $matches);
if ($last_user == "") continue;
if ($matches['mode'] == 'A') {
$usr_adds[$last_user]++;
return false ;
}
+ // Skip empty repo (no HEAD present in repository)
+ $ref = trim(`GIT_DIR=$repo git symbolic-ref HEAD`);
+ if (!file_exists($repo.'/'.$ref)) {
+ return false;
+ }
+
$tmp = trim (`mktemp -d`) ;
if ($tmp == '') {
return false ;