[Fusionforge-commits] r7999 - trunk/gforge/plugins/scmcpold/common

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Aug 27 15:42:29 CEST 2009


Author: lolando
Date: 2009-08-27 15:42:29 +0200 (Thu, 27 Aug 2009)
New Revision: 7999

Modified:
   trunk/gforge/plugins/scmcpold/common/CpoldPlugin.class.php
Log:
Added tarball generation to cpold plugin

Modified: trunk/gforge/plugins/scmcpold/common/CpoldPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmcpold/common/CpoldPlugin.class.php	2009-08-27 13:42:19 UTC (rev 7998)
+++ trunk/gforge/plugins/scmcpold/common/CpoldPlugin.class.php	2009-08-27 13:42:29 UTC (rev 7999)
@@ -27,6 +27,7 @@
 		$this->SCMPlugin () ;
 		$this->name = 'scmcpold';
 		$this->text = 'CPOLD';
+		$this->hooks[] = 'scm_generate_snapshots' ;
 		$this->hooks[] = 'scm_cpold_do_nothing' ;
 		
 		require_once $gfconfig.'plugins/scmcpold/config.php' ;
@@ -102,6 +103,43 @@
 			system ("chmod -R g+wXs,o-rwx $repo") ;
 		}
 	}
+
+	function generateSnapshots ($params) {
+		global $sys_scm_tarballs_path ;
+
+		$project = $this->checkParams ($params) ;
+		if (!$project) {
+			return false ;
+		}
+		
+		$group_name = $project->getUnixName() ;
+
+		$tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
+
+		if (! $project->usesPlugin ($this->name)
+		    || ! $project->enableAnonSCM()) {
+			unlink ($tarball) ;
+			return false;
+		}
+
+		$toprepo = $this->cpold_root ;
+		$repo = $toprepo . '/' . $project->getUnixName() ;
+
+		if (!is_dir ($repo)) {
+			unlink ($tarball) ;
+			return false ;
+		}
+
+		$tmp = trim (`mktemp -d`) ;
+		if ($tmp == '') {
+			return false ;
+		}
+		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
+		chmod ("$tmp/tarball.tar.gz", 0644) ;
+		copy ("$tmp/tarball.tar.gz", $tarball) ;
+		unlink ("$tmp/tarball.tar.gz") ;
+		system ("rm -rf $tmp") ;
+	}
   }
 
 // Local Variables:




More information about the Fusionforge-commits mailing list