[Fusionforge-commits] r9966 - in trunk/gforge: common/include plugins/cvstracker/bin plugins/cvstracker/www plugins/scmcvs/cronjobs plugins/svntracker/bin plugins/svntracker/www

Roland Mas lolando at libremir.placard.fr.eu.org
Wed Jun 2 17:15:52 CEST 2010


Author: lolando
Date: 2010-06-02 17:15:51 +0200 (Wed, 02 Jun 2010)
New Revision: 9966

Modified:
   trunk/gforge/common/include/utils.php
   trunk/gforge/plugins/cvstracker/bin/post.php
   trunk/gforge/plugins/cvstracker/www/newcommit.php
   trunk/gforge/plugins/scmcvs/cronjobs/cvs.php
   trunk/gforge/plugins/svntracker/bin/post.php
   trunk/gforge/plugins/svntracker/www/newcommit.php
Log:
Config API: cvstracker and svntracker plugins (with some side changes for detecting CVS version)

Modified: trunk/gforge/common/include/utils.php
===================================================================
--- trunk/gforge/common/include/utils.php	2010-06-02 14:21:25 UTC (rev 9965)
+++ trunk/gforge/common/include/utils.php	2010-06-02 15:15:51 UTC (rev 9966)
@@ -1212,6 +1212,17 @@
 	return false;
 }
 
+function get_cvs_binary_version () {
+	$string = `cvs --version 2>/dev/null | grep ^Concurrent.Versions.System.*client/server` ;
+	if (preg_match ('/^Concurrent Versions System .CVS. 1.11.[0-9]*/', $string)) {
+		return '1.11' ;
+	} elseif (preg_match ('/^Concurrent Versions System .CVS. 1.12.[0-9]*/', $string)) {
+		return '1.12' ;
+	} else {
+		return '' ;
+	}
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Modified: trunk/gforge/plugins/cvstracker/bin/post.php
===================================================================
--- trunk/gforge/plugins/cvstracker/bin/post.php	2010-06-02 14:21:25 UTC (rev 9965)
+++ trunk/gforge/plugins/cvstracker/bin/post.php	2010-06-02 15:15:51 UTC (rev 9966)
@@ -30,12 +30,12 @@
  *
  */
  
-//require ('local.inc'); we don't need this file. also, in some installations this file cannot be accessed by the caller (perms problem)
 require dirname(__FILE__).'/../../env.inc.php';
-require_once ($gfconfig.'plugins/cvstracker/config.php');
+require_once $gfwww.'include/pre.php';
 require_once ($gfcommon.'common/include/utils.php');
 require_once ($gfplugins.'cvstracker/common/Snoopy.class.php');
 
+$cvs_binary_version = get_cvs_binary_version () ;
 
 if ($cvs_binary_version != "1.12" &&
 	$cvs_binary_version != "1.11" )
@@ -118,12 +118,6 @@
 
 $files = array();
 
-if($cvs_tracker_debug) {
-	echo "Arguments count: ".$argc."\n";
-	echo "Arguments passed to post.php:\n";
-	print_r($argv);
-}
-
 if( $cvs_binary_version == "1.11" ) {
 	if ($argc <= 3 ) {
 		usage ( $argv );
@@ -206,12 +200,7 @@
 	$i++;
 }
 	
-	if($cvs_tracker_debug) {
-		echo "Variables submitted to newcommit.php:\n";
-		print_r($SubmitVars);
-	}
-	$vars['data'] = serialize($SubmitVars);
-	$snoopy->submit($SubmitUrl,$vars);
-	print $snoopy->results;
+$vars['data'] = serialize($SubmitVars);
+$snoopy->submit($SubmitUrl,$vars);
 
 ?>

Modified: trunk/gforge/plugins/cvstracker/www/newcommit.php
===================================================================
--- trunk/gforge/plugins/cvstracker/www/newcommit.php	2010-06-02 14:21:25 UTC (rev 9965)
+++ trunk/gforge/plugins/cvstracker/www/newcommit.php	2010-06-02 15:15:51 UTC (rev 9966)
@@ -41,10 +41,6 @@
 	$Configs[$i]['Log']             = $SubmittedVar['Log'];
 	$Configs[$i]['CvsDate']         = $SubmittedVar['CvsDate'];
 	$i++;
-	if($cvs_tracker_debug) {
-		echo "Variables received by newcommit.php:\n";
-		print_r($Configs[$i]);
-	}
 }
 
 
@@ -60,7 +56,7 @@
  */
 function parseConfig($Config)
 {
-	global $sys_cvsroot_path, $cvs_tracker_debug;
+	$repos_path = forge_get_config ('repos_path', 'scmcvs') ;
 	
 	$Result = array();
 	$Result['check'] = true;
@@ -68,19 +64,14 @@
 	$UserName = $Config['UserName'];
 
 	// add a trailing / if needed
-	if($sys_cvsroot_path[strlen($sys_cvsroot_path)-1]!='/') {
-		$sys_cvsroot_path.='/';
+	if($repos_path[strlen($repos_path)-1]!='/') {
+		$repos_path.='/';
 	}
-	if(strncmp($Repository,$sys_cvsroot_path, strlen($sys_cvsroot_path)) == 0) {
-		$GroupName = substr($Repository, strlen($sys_cvsroot_path));
+	if(strncmp($Repository,$repos_path, strlen($repos_path)) == 0) {
+		$GroupName = substr($Repository, strlen($repos_path));
 	} else {
 		$GroupName = $Repository;
 	}
-	if($cvs_tracker_debug) {
-		echo "GroupName = ".$GroupName."\n";
-		echo "CVSRootPath = ".$sys_cvsroot_path."\n";
-	}
-
 	
 	$Result['user']     = user_get_object_by_name($UserName);
 	if (!$Result['user'] || !is_object($Result['user']) ||

Modified: trunk/gforge/plugins/scmcvs/cronjobs/cvs.php
===================================================================
--- trunk/gforge/plugins/scmcvs/cronjobs/cvs.php	2010-06-02 14:21:25 UTC (rev 9965)
+++ trunk/gforge/plugins/scmcvs/cronjobs/cvs.php	2010-06-02 15:15:51 UTC (rev 9966)
@@ -26,6 +26,7 @@
 require dirname(__FILE__).'/../../env.inc.php';
 require_once $gfwww.'include/pre.php';
 require $gfcommon.'include/cron_utils.php';
+require $gfcommon.'include/utils.php';
 require_once $gfcommon.'mail/MailingList.class.php';
 require_once $gfcommon.'mail/MailingListFactory.class.php';
 
@@ -142,7 +143,8 @@
  */
 function add_sync_mail($unix_group_name) {
 
-	global  $cvsdir_prefix, $cvs_binary_version;
+	global  $cvsdir_prefix ;
+	$cvs_binary_version = get_cvs_binary_version () ;
 	$loginfo_file=$cvsdir_prefix.'/'.$unix_group_name.'/CVSROOT/loginfo';
 
 	if (!$loginfo_file) {
@@ -182,7 +184,8 @@
  *
  */
 function add_cvstracker($unix_group_name) {
-	global $cvsdir_prefix, $cvs_binary_version;
+	global $cvsdir_prefix;
+	$cvs_binary_version = get_cvs_binary_version () ;
 	$loginfo_file=$cvsdir_prefix.'/'.$unix_group_name.'/CVSROOT/loginfo';
 
 	if (!$loginfo_file) {
@@ -247,7 +250,8 @@
 }
 
 function add_acl_check($unix_group_name) {
-	global $cvsdir_prefix, $cvs_binary_version;
+	global $cvsdir_prefix;
+	$cvs_binary_version = get_cvs_binary_version () ;
 
 	$commitinfofile = $cvsdir_prefix."/".$unix_group_name.'/CVSROOT/commitinfo';
 

Modified: trunk/gforge/plugins/svntracker/bin/post.php
===================================================================
--- trunk/gforge/plugins/svntracker/bin/post.php	2010-06-02 14:21:25 UTC (rev 9965)
+++ trunk/gforge/plugins/svntracker/bin/post.php	2010-06-02 15:15:51 UTC (rev 9966)
@@ -30,14 +30,9 @@
  *
  */
 
-
-require $gfconfig.'plugins/svntracker/config.php';
+require_once $gfwww.'include/pre.php';
 require $gfplugins.'svntracker/common/Snoopy.class.php';
 
-if ($svn_tracker_debug) {
-	$file = fopen($svn_tracker_debug_file,"a+");	
-}
-
 /**
  * It returns the usage and exit program
  *
@@ -168,16 +163,7 @@
 // Our POSTer in Gforge
 $snoopy = new Snoopy;
 
-if ($use_ssl) {
-	$http = "https://";
-} else {
-	$http = "http://";
-}
-
 $SubmitUrl = util_make_url('/plugins/svntracker/newcommit.php');
-if ($svn_tracker_debug) {
-	fwrite($file,"submiturl : " . $SubmitUrl . "\n");
-}
 
 $tasks_involved= getInvolvedTasks($log);
 $artifacts_involved= getInvolvedArtifacts($log);
@@ -201,20 +187,6 @@
 	$SubmitVars[$i]["SvnDate"]         = time();
 	$i++;
 }
-	$vars['data'] = serialize($SubmitVars);
-	if($svn_tracker_debug) {
-		echo "Variables submitted to newcommit.php:\n";
-		print_r($SubmitVars);
-		fwrite($file,"Variables submitted to newcommit.php:\n");
-		fwrite($file,print_r($SubmitVars));
-	}
-	$snoopy->submit($SubmitUrl,$vars);
-	if ($svn_tracker_debug) {
-	    print_r($snoopy->results);
-	    print_r($snoopy->error);
-	    fwrite($file,$snoopy->results);
-		fwrite($file,$snoopy->error);
-	}
-
-
+$vars['data'] = serialize($SubmitVars);
+$snoopy->submit($SubmitUrl,$vars);
 ?>

Modified: trunk/gforge/plugins/svntracker/www/newcommit.php
===================================================================
--- trunk/gforge/plugins/svntracker/www/newcommit.php	2010-06-02 14:21:25 UTC (rev 9965)
+++ trunk/gforge/plugins/svntracker/www/newcommit.php	2010-06-02 15:15:51 UTC (rev 9966)
@@ -18,12 +18,7 @@
 
 require_once dirname(__FILE__)."/../../env.inc.php";
 require_once $gfwww.'include/pre.php';
-require_once $gfconfig.'plugins/svntracker/config.php';
 
-if ($svn_tracker_debug) {
-	$file = fopen($svn_tracker_debug_file,"a+");	
-}
-
 /**
  * Getting POST variables
  * UserName, Repository, Path, FileName, PrevVersion, ActualVersion, Log,
@@ -67,19 +62,19 @@
  */
 function parseConfig(&$Config)
 {
-	global $sys_svnroot_path, $svn_tracker_debug,$file;
+	$repos_path = forge_get_config ('repos_path', 'scmsvn') ;
 	
 	$Result = array();
 	$Result['check'] = true;
 	$Repository = $Config['Repository'];
 	$UserName = $Config['UserName'];
 
-	if($sys_svnroot_path[strlen($sys_svnroot_path)-1]!='/') {
-		$sys_svnroot_path.='/';
+	if($repos_path[strlen($repos_path)-1]!='/') {
+		$repos_path.='/';
 	}
 	$repo_root = substr($Repository,0,strrpos($Repository,"/") + 1); //we get the directory of the repository root (with trailing slash)
 	
-	if(fileinode($sys_svnroot_path) == fileinode($repo_root)) { // since the $sys_svnroot_path is usually $sys_svnroot, and that one is a symlink, we check that the inode is the same for both
+	if(fileinode($repos_path) == fileinode($repo_root)) { // since the $repos_path is usually $sys_svnroot, and that one is a symlink, we check that the inode is the same for both
 		$GroupName = substr($Repository, strrpos($Repository,"/") + 1);
 		$Config['FileName'] = substr($Config['FileName'],strlen($Repository)); //get only the filename relative to the repo
 	} else {
@@ -89,13 +84,9 @@
 	
 	if($svn_tracker_debug) {
 		echo "GroupName = ".$GroupName."\n";
-		echo "SVNRootPath = ".$sys_svnroot_path."\n";
+		echo "SVNRootPath = ".$repos_path."\n";
 	}
 	
-	if ($svn_tracker_debug) {
-		fwrite($file,$GroupName."\n");
-	}
-	
 	$Result['group']    = group_get_object_by_name($GroupName);
 	$Result['user']     = user_get_object_by_name($UserName);
 	if (!$Result['group'] || !is_object($Result['group']) ||
@@ -129,7 +120,6 @@
  */
 function addArtifactLog($Config, $GroupId, $Num)
 {
-	global $file, $svn_tracker_debug;
 	$return = array();
 	$Result = db_query_params ('SELECT * FROM artifact,artifact_group_list WHERE 
 artifact.group_artifact_id=artifact_group_list.group_artifact_id 
@@ -137,10 +127,6 @@
 				   array ($GroupId,
 					  $Num));
 	$Rows = db_numrows($Result);
-	if ($svn_tracker_debug) {
-		fwrite($file,"query : " . $Query ."\n");
-		fwrite($file,"rows : " . $Rows ."\n");
-	}
 	if ($Rows == 0) {
 		$return['Error'] = "Artifact ".$Num." Not Found.";
 	}




More information about the Fusionforge-commits mailing list