[Fusionforge-commits] r8167 - trunk/gforge/plugins/scmgit/common

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Sep 24 18:45:45 CEST 2009


Author: lolando
Date: 2009-09-24 18:45:45 +0200 (Thu, 24 Sep 2009)
New Revision: 8167

Modified:
   trunk/gforge/plugins/scmgit/common/GitPlugin.class.php
Log:
Put the default git repository one level deeper to accomodate multiple
repositories more easily.
  
Fix the permissions setting code:
- start on the root directory to affect all git repos
- init the repository in a way that git ensures correct permissions
  (--shared=group).
- put setgid rights on directories only


Modified: trunk/gforge/plugins/scmgit/common/GitPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmgit/common/GitPlugin.class.php	2009-09-24 14:14:55 UTC (rev 8166)
+++ trunk/gforge/plugins/scmgit/common/GitPlugin.class.php	2009-09-24 16:45:45 UTC (rev 8167)
@@ -111,7 +111,7 @@
 		
 		if ($project->usesPlugin ($this->name)) {
 			if ($this->browserDisplayable ($project)) {
-				print '<iframe src="'.util_make_url ("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName()).'" frameborder="no" width=100% height=700></iframe>' ;
+				print '<iframe src="'.util_make_url ("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/'.$project->getUnixName().'.git').'" frameborder="no" width=100% height=700></iframe>' ;
 			}
 		}
 	}
@@ -184,12 +184,13 @@
 		}
 
 		$project_name = $project->getUnixName() ;
-		$repo = $this->git_root . '/' . $project_name ;
+		$root = $this->git_root . '/' . $project_name ;
+		$repo = $root . '/' .  $project_name . '.git' ;
 		$unix_group = 'scm_' . $project_name ;
 
 		system ("mkdir -p $repo") ;
 		if (!is_file ("$repo/HEAD") && !is_dir("$repo/objects") && !is_dir("$repo/refs")) {
-			system ("GIT_DIR=\"$repo\" git --bare init") ;
+			system ("GIT_DIR=\"$repo\" git init --bare --shared=group") ;
 			system ("GIT_DIR=\"$repo\" git update-server-info") ;
 			if (is_file ("$repo/hooks/post-update.sample")) {
 				rename ("$repo/hooks/post-update.sample",
@@ -207,11 +208,13 @@
 			system ("find $repo -type d | xargs chmod g+s") ;
 		}
 
-		system ("chgrp -R $unix_group $repo") ;
+		system ("chgrp -R $unix_group $root") ;
 		if ($project->enableAnonSCM()) {
-			system ("chmod -R g+wX,o+rX-w $repo") ;
+			system ("chmod -R g+wX,o+rX-w $root") ;
+                        system ("find $root -type d -print0 | xargs --null chmod g+s");
 		} else {
-			system ("chmod -R g+wX,o-rwx $repo") ;
+			system ("chmod -R g+wX,o-rwx $root") ;
+                        system ("find $root -type d -print0 | xargs --null chmod g+s");
 		}
 	}
 
@@ -243,7 +246,7 @@
 
 		$f = fopen ($fname.'.new', 'w') ;
 		foreach ($list as $project) {
-			fwrite ($f, $project->getUnixName() . "\n");
+			fwrite ($f, $project->getUnixName() . "/" .  $project->getUnixName() . ".git\n");
 		}
 		fclose ($f) ;
 		chmod ($fname.'.new', 0644) ;
@@ -272,8 +275,9 @@
 			return false;
 		}
 
+                // TODO: ideally we generate one snapshot per git repository
 		$toprepo = $this->git_root ;
-		$repo = $toprepo . '/' . $project->getUnixName() ;
+		$repo = $toprepo . '/' . $project->getUnixName() . '/' .  $project->getUnixName() . '.git' ;
 
 		if (!is_dir ($repo)) {
 			unlink ($tarball) ;




More information about the Fusionforge-commits mailing list