$this->name = 'scmsvn';
$this->text = 'SVN';
$this->hooks[] = 'scm_browser_page';
+ $this->hooks[] = 'scm_update_repolist' ;
$this->hooks[] = 'scm_generate_snapshots' ;
$this->hooks[] = 'scm_gather_stats' ;
require_once $gfconfig.'plugins/scmsvn/config.php' ;
$this->default_svn_server = $default_svn_server ;
- $this->enabled_by_default = $enabled_by_default ;
$this->use_ssh = $use_ssh;
$this->use_dav = $use_dav;
$this->use_ssl = $use_ssl;
- $this->svn_root = $svn_root;
+ if (isset ($svn_root)) {
+ $this->svn_root = $svn_root;
+ } else {
+ $this->svn_root = $GLOBALS['sys_chroot'].'/scmrepos/svn' ;
+ }
$this->register () ;
}
$b = _('<p><b>Anonymous Subversion Access</b></p><p>This project\'s SVN repository can be checked out through anonymous access with the following command(s).</p>');
$b .= '<p>' ;
if ($this->use_ssh) {
- $b .= '<tt>svn checkout svn://'.$project->getSCMBox().'/'.$this->svn_root.'/'.$project->getUnixName().'</tt><br />';
+ $b .= '<tt>svn checkout svn://'.$project->getSCMBox().$this->svn_root.'/'.$project->getUnixName().'</tt><br />';
}
if ($this->use_dav) {
- $b .= '<tt>svn checkout --username anonsvn http'.(($this->use_ssl) ? 's' : '').'://' . $project->getSCMBox(). '/' . $this->svn_root .'/'. $project->getUnixName() .'</tt><br/><br/>';
+ $b .= '<tt>svn checkout --username anonsvn http'.(($this->use_ssl) ? 's' : '').'://' . $project->getSCMBox(). $this->svn_root .'/'. $project->getUnixName() .'</tt><br/><br/>';
$b .= _('The password is \'anonsvn\'').'<br/>';
}
$b .= '</p>';
$b = '' ;
if ($this->use_ssh) {
$b .= _('<p><b>Developer Subversion Access via SSH</b></p><p>Only project developers can access the SVN 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>');
- $b .= '<p><tt>svn checkout svn+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . '/'. $this->svn_root .'/'. $project->getUnixName().'</tt></p>' ;
+ $b .= '<p><tt>svn checkout svn+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . $this->svn_root .'/'. $project->getUnixName().'</tt></p>' ;
}
if ($this->use_dav) {
$b .= _('<p><b>Developer Subversion Access via DAV</b></p><p>Only project developers can access the SVN tree via this method. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.</p>');
- $b .= '<p><tt>svn checkout --username <i>'._('developername').'</i> http'.(($this->use_ssl) ? 's' : '').'://'. $project->getSCMBox() .'/'. $this->svn_root .'/'.$project->getUnixName().'</tt></p>' ;
+ $b .= '<p><tt>svn checkout --username <i>'._('developername').'</i> http'.(($this->use_ssl) ? 's' : '').'://'. $project->getSCMBox() . $this->svn_root .'/'.$project->getUnixName().'</tt></p>' ;
}
return $b ;
$unix_group = 'scm_' . $project->getUnixName() ;
if (!is_dir ($repo) || !is_file ("$repo/format")) {
- system ("svnadmin create --fs-type fsfs $repo") ;
+ system ("svnadmin create $repo") ;
+ system ("svn mkdir -m'Init' file:///$repo/trunk file:///$repo/tags file:///$repo/branches") ;
+ system ("find $repo -type d | xargs chmod g+s") ;
}
- system ("chgrp -R $unix_group $repo") ;
- if ($project->enableAnonSCM()) {
- system ("chmod -R g+wXs,o+rX-w $repo") ;
+ if ($this->use_ssh) {
+ system ("chgrp -R $unix_group $repo") ;
+ if ($project->enableAnonSCM()) {
+ system ("chmod -R g+wX,o+rX-w $repo") ;
+ } else {
+ system ("chmod -R g+wX,o-rwx $repo") ;
+ }
} else {
- system ("chmod -R g+wXs,o-rwx $repo") ;
+ $unix_user = $GLOBALS['sys_apache_user'];
+ system ("chown -R $unix_user:$unix_group $repo") ;
+ if ($project->enableAnonSCM()) {
+ system ("chmod -R g+wX,o+rX-w $repo") ;
+ } else {
+ system ("chmod -R g+wX,o-rwx $repo") ;
+ }
+ }
+ }
+
+ function updateRepositoryList ($params) {
+ $groups = $this->getGroups () ;
+
+ // Update WebDAV stuff
+ if (!$this->use_dav) {
+ return true ;
+ }
+
+ $access_data = '' ;
+ $password_data = '' ;
+
+ $svnusers = array () ;
+ foreach ($groups as $project) {
+ $users = $project->getMembers () ;
+ $perm = $project->getPermission ($user) ;
+ if ($perm->isMember ('scm', 0)) {
+ $svnusers[$user->getID()] = $user ;
+ }
+
+ $access_data .= '[' . $project->getUnixName () . ":/]\n" ;
+ if ($perm->isMember ('scm', 1)) {
+ $access_data .= $user->getUnixName() . "= rw\n" ;
+ } elseif ($perm->isMember ('scm', 0)) {
+ $access_data .= $user->getUnixName() . "= r\n" ;
+ }
+ if ( $project->enableAnonSCM() ) {
+ $access_data .= "anonsvn= r\n" ;
+ $access_data .= "* = r\n" ;
+
+ }
+ $access_data .= "\n" ;
}
+
+ foreach ($svnusers as $user_id => $user) {
+ $password_data .= $user->getUnixName ().':'.$user->getMD5Passwd ()."\n" ;
+ }
+ $password_data .= "anonsvn:$apr1$Kfr69/..$J08mbyNpD81y42x7xlFDm.\n" ;
+
+ $fname = $sys_var_path.'/svnroot-access' ;
+ $f = fopen ($fname.'.new', 'w') ;
+ fwrite ($f, $password_data) ;
+ fclose ($f) ;
+ chmod ($fname.'.new', 0644) ;
+ rename ($fname.'.new', $fname) ;
+
+ $fname = $sys_var_path.'/svnroot-authfile' ;
+ $f = fopen ($fname.'.new', 'w') ;
+ fwrite ($f, $access_data) ;
+ fclose ($f) ;
+ chmod ($fname.'.new', 0644) ;
+ rename ($fname.'.new', $fname) ;
}
function gatherStats ($params) {
global $last_user, $last_time, $last_tag, $time_ok, $start_time, $end_time,
$adds, $deletes, $updates, $commits, $date_key,
$usr_adds, $usr_deletes, $usr_updates;
+
+ $time_ok = true ;
$project = $this->checkParams ($params) ;
if (!$project) {
return false ;
}
- $pipe = popen ("svn log file://$repo --xml -v -q", 'r' ) ;
+ $d1 = date ('Y-m-d', $start_time - 150000) ;
+ $d2 = date ('Y-m-d', $end_time + 150000) ;
+
+ $pipe = popen ("svn log file://$repo --xml -v -q -r '".'{'.$d2.'}:{'.$d1.'}'."' 2> /dev/null", 'r' ) ;
// 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',
break;
}
- if (!$time_ok && $last_time && $last_time < $start_time) {
+ if (!$time_ok && $last_time && $last_time > $end_time) {
break;
}
}
xml_parser_free ($xml_parser);
- //..................
-
// inserting group results in stats_cvs_groups
- if (!db_query_params ('INSERT INTO stats_cvs_group (month,day,group_id,checkouts,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
- array ($month_string,
- $day,
- $project->getID(),
- 0,
- $updates,
- $adds))) {
- echo "Error while inserting into stats_cvs_group\n" ;
- db_rollback () ;
- return false ;
+ if ($updates > 0 || $adds > 0) {
+ if (!db_query_params ('INSERT INTO stats_cvs_group (month,day,group_id,checkouts,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
+ array ($month_string,
+ $day,
+ $project->getID(),
+ 0,
+ $updates,
+ $adds))) {
+ echo "Error while inserting into stats_cvs_group\n" ;
+ db_rollback () ;
+ return false ;
+ }
}
// building the user list
- $user_list = array_unique( array_merge( array_keys( $usr_add ), array_keys( $usr_commit ) ) );
+ $user_list = array_unique( array_merge( array_keys( $usr_adds ), array_keys( $usr_updates ) ) );
foreach ( $user_list as $user ) {
// trying to get user id from user name
} else {
continue;
}
-
- if (!db_query_params ('INSERT INTO stats_cvs_user (month,day,group_id,user_id,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
- array ($month_string,
- $day,
- $project->getID(),
- $user_id,
- $usr_commit[$user] ? $usr_commit[$user] : 0,
- $usr_add[$user] ? $usr_add[$user] : 0))) {
- echo "Error while inserting into stats_cvs_user\n" ;
- db_rollback () ;
- return false ;
+
+ $uu = $usr_updates[$user] ? $usr_updates[$user] : 0 ;
+ $ua = $usr_adds[$user] ? $usr_adds[$user] : 0 ;
+ if ($uu > 0 || $ua > 0) {
+ if (!db_query_params ('INSERT INTO stats_cvs_user (month,day,group_id,user_id,commits,adds) VALUES ($1,$2,$3,$4,$5,$6)',
+ array ($month_string,
+ $day,
+ $project->getID(),
+ $user_id,
+ $uu,
+ $ua))) {
+ echo "Error while inserting into stats_cvs_user\n" ;
+ db_rollback () ;
+ return false ;
+ }
}
}
}
$snapshot = $sys_scm_snapshots_path.'/'.$group_name.'-scm-latest.tar.gz';
$tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
- if (! $project->usesPlugin ($this->name)
- || ! $project->enableAnonSCM()) {
+ if (! $project->usesPlugin ($this->name)) {
+ return false;
+ }
+
+ if (! $project->enableAnonSCM()) {
unlink ($snapshot) ;
unlink ($tarball) ;
return false;