[evolvis-commits] r16881: Test for presence of /trunk before suggesting what to svn checkout (patch [#240] by Sylvain Le Gall)

mirabilos at evolvis.org mirabilos at evolvis.org
Tue Mar 1 01:45:51 CET 2011


Author: mirabilos
Date: 2011-03-01 01:45:51 +0100 (Tue, 01 Mar 2011)
New Revision: 16881

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/common/SVNPlugin.class.php
Log:
Test for presence of /trunk before suggesting what to svn checkout (patch [#240] by Sylvain Le Gall)

Modified: trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/common/SVNPlugin.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/common/SVNPlugin.class.php	2011-03-01 00:45:42 UTC (rev 16880)
+++ trunk/gforge_base/evolvisforge-5.1/src/plugins/scmsvn/common/SVNPlugin.class.php	2011-03-01 00:45:51 UTC (rev 16881)
@@ -79,6 +79,19 @@
 		return '<p>' . _('Documentation for Subversion (sometimes referred to as "SVN") is available <a href="http://svnbook.red-bean.com/">here</a>.') . '</p>';
 	}
 
+	function topModule ($project) {
+		// Check toplevel module presence
+		$repo = 'file://' . forge_get_config('repos_path', $this->name).'/'.$project->getUnixName().'/';
+		$res = array ();
+		$module = 'trunk';
+		if (!(exec("svn ls '$repo'", $res) && in_array($module.'/', $res)))
+		{
+			$module = '';
+		}
+
+		return '/'.$module;
+	}
+
 	function getInstructionsForAnon ($project) {
 		$b = '<h2>' . _('Anonymous Subversion Access') . '</h2>';
 		$b .= '<p>';
@@ -86,11 +99,12 @@
 		$b .= '</p>';
 
 		$b .= '<p>' ;
+		$module = $this->topModule($project);
 		if (forge_get_config('use_ssh', 'scmsvn')) {
-			$b .= '<tt>svn checkout svn://'.$project->getSCMBox().$this->svn_root.'/'.$project->getUnixName().'/trunk</tt><br />';
+			$b .= '<tt>svn checkout svn://'.$project->getSCMBox().$this->svn_root.'/'.$project->getUnixName().$module.'</tt><br />';
 		}
 		if (forge_get_config('use_dav', 'scmsvn')) {
-			$b .= '<tt>svn checkout --username '.forge_get_config('anonsvn_login', 'scmsvn').' http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://' . $project->getSCMBox(). $this->svn_root .'/'. $project->getUnixName() .'/trunk</tt><br/><br/>';
+			$b .= '<tt>svn checkout --username '.forge_get_config('anonsvn_login', 'scmsvn').' http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://' . $project->getSCMBox(). $this->svn_root .'/'. $project->getUnixName() .$module.'</tt><br/><br/>';
 			$b .= _('The password is ').forge_get_config('anonsvn_password', 'scmsvn').'<br/>';
 		}
 		$b .= '</p>';
@@ -99,6 +113,9 @@
 
 	function getInstructionsForRW ($project) {
 		$b = '' ;
+
+		$module = $this->topModule($project);
+
 		if (session_loggedin()) {
 			$u =& user_get_object(user_getid()) ;
 			$d = $u->getUnixName() ;
@@ -109,7 +126,7 @@
 				$b .= '<p>';
 				$b .= _('Only project developers can access the SVN tree via this method. SSH must be installed on your client machine. Enter your site password when prompted.');
 				$b .= '</p>';
-				$b .= '<p><tt>svn checkout svn+ssh://'.$d.'@' . $project->getSCMBox() . $this->svn_root .'/'. $project->getUnixName().'/trunk</tt></p>' ;
+				$b .= '<p><tt>svn checkout svn+ssh://'.$d.'@' . $project->getSCMBox() . $this->svn_root .'/'. $project->getUnixName().$module.'</tt></p>' ;
 			}
 			if (forge_get_config('use_dav', 'scmsvn')) {
 				$b .= '<h2>';
@@ -118,7 +135,7 @@
 				$b .= '<p>';
 				$b .= _('Only project developers can access the SVN tree via this method. Enter your site password when prompted.');
 				$b .= '</p>';
-				$b .= '<p><tt>svn checkout --username '.$d.' http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $project->getSCMBox() . $this->svn_root .'/'.$project->getUnixName().'/trunk</tt></p>' ;
+				$b .= '<p><tt>svn checkout --username '.$d.' http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $project->getSCMBox() . $this->svn_root .'/'.$project->getUnixName().$module.'</tt></p>' ;
 			}
 		} else {
 			if (forge_get_config('use_ssh', 'scmsvn')) {
@@ -128,7 +145,7 @@
 				$b .= '<p>';
 				$b .= _('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.');
 				$b .= '</p>';
-				$b .= '<p><tt>svn checkout svn+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . $this->svn_root .'/'. $project->getUnixName().'/trunk</tt></p>' ;
+				$b .= '<p><tt>svn checkout svn+ssh://<i>'._('developername').'</i>@' . $project->getSCMBox() . $this->svn_root .'/'. $project->getUnixName().$module.'</tt></p>' ;
 			}
 			if (forge_get_config('use_dav', 'scmsvn')) {
 				$b .= '<h2>';
@@ -137,7 +154,7 @@
 				$b .= '<p>';
 				$b .= _('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.');
 				$b .= '</p>';
-				$b .= '<p><tt>svn checkout --username <i>'._('developername').'</i> http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $project->getSCMBox() . $this->svn_root .'/'.$project->getUnixName().'/trunk</tt></p>' ;
+				$b .= '<p><tt>svn checkout --username <i>'._('developername').'</i> http'.((forge_get_config('use_ssl', 'scmsvn')) ? 's' : '').'://'. $project->getSCMBox() . $this->svn_root .'/'.$project->getUnixName().$module.'</tt></p>' ;
 			}
 		}
 		return $b ;



More information about the evolvis-commits mailing list