/** * Create SVN repositories * * @param string Project name * @param bool Create standard directories (/trunk, /tags, /branches) */ private static function createProjectSVN($project_name, $create_dir) { $config = Zend_Registry::get('config'); $path = $config->subversion->path . DIRECTORY_SEPARATOR . 'svn' . DIRECTORY_SEPARATOR . $project_name; if (!USVN_SVNUtils::isSVNRepository($path, true)) { $directories = explode(DIRECTORY_SEPARATOR, $path); $tmp_path = ''; foreach ($directories as $directory) { $tmp_path .= $directory . DIRECTORY_SEPARATOR; if (USVN_SVNUtils::isSVNRepository($tmp_path)) { $tmp_path = ''; break; } } if ($tmp_path === $path . DIRECTORY_SEPARATOR) { @mkdir($path, 0700, true); USVN_SVNUtils::createSVN($path); if ($create_dir) { USVN_SVNUtils::createStandardDirectories($path); } } else { $message = "One of these repository's subfolders is a subversion repository."; throw new USVN_Exception(T_("Can't create subversion repository:<br />%s"), $message); } } else { $message = $project_name . " is a SVN repository."; throw new USVN_Exception(T_("Can't create subversion repository:<br />%s"), $message); } }
/** * Create SVN repositories * * @param string Project name * @param bool Create standard directories (/trunk, /tags, /branches) */ private static function createProjectSVN($project_name, $create_dir) { $config = Zend_Registry::get('config'); $path = $config->subversion->path . DIRECTORY_SEPARATOR . 'svn' . DIRECTORY_SEPARATOR . $project_name; if (!USVN_SVNUtils::isSVNRepository($path, true)) { $directories = explode(DIRECTORY_SEPARATOR, $path); $tmp_path = ''; foreach ($directories as $directory) { $tmp_path .= $directory . DIRECTORY_SEPARATOR; if (USVN_SVNUtils::isSVNRepository($tmp_path)) { $tmp_path = ''; break; } } if ($tmp_path === $path . DIRECTORY_SEPARATOR) { if ($mod = $config->subversion->chmod) { $mod = intval($mod, 8); } else { $mod = 0700; } @mkdir($path, $mod, true); @chmod($path, $mod); // mkdir is bogus USVN_SVNUtils::createSVN($path); if ($create_dir) { USVN_SVNUtils::createStandardDirectories($path); } // apply files rights $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $file) { @chmod((string) $file, $mod); } // apply special dir rights on repo/db if ($mod = $config->subversion->chmod_db) { $mod = intval($mod, 8); $dbPath = $path . '/db'; @chmod($dbPath, $mod); $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dbPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $file) { if ($file->isDir()) { @chmod((string) $file, $mod); } } //$escape_path = escapeshellarg($path); //USVN_ConsoleUtils::runCmdCaptureMessage("chmod g+s $escape_path/*/db && find $escape_path/*/db -type d ! -perm -g=s | xargs chmod g+s", $return); //@USVN_DirectoryUtils::chmodRecursive($path.'/db', intval($mod, 8)); } } else { $message = "One of these repository's subfolders is a subversion repository."; throw new USVN_Exception(T_("Can't create subversion repository:<br />%s"), $message); } } else { $message = $project_name . " is a SVN repository."; throw new USVN_Exception(T_("Can't create subversion repository:<br />%s"), $message); } }
public function testInsertProjectOkSVNAlreadyExist() { USVN_SVNUtils::createSVN('tests/tmp/' . DIRECTORY_SEPARATOR . 'svn' . DIRECTORY_SEPARATOR . 'InsertProjectOk'); $table = new USVN_Db_Table_Projects(); $project = $table->fetchNew(); $project->setFromArray(array('projects_name' => 'InsertProjectOk', 'projects_start_date' => '1984-12-03 00:00:00')); $project->save(); $this->assertTrue($table->isAProject('InsertProjectOk'), "Le projet n'est pas cree"); $this->assertTrue(USVN_SVNUtils::isSVNRepository('tests/tmp/svn/InsertProjectOk'), "Le repository n'est pas cree"); }
/** * Check if a SVN repository can be imported * * @param string $path * @throws USVN_Exception * @return bool */ public static function canBeImported($path, $options = array('verbose' => false)) { if (!is_string($path)) { throw new USVN_Exception(T_('%s must be a string: %s'), '$path'); } $config = Zend_Registry::get('config'); $path = realpath($path); if (USVN_DirectoryUtils::firstDirectoryIsInclude($path, $config->subversion->path)) { if (is_dir($path) && USVN_SVNUtils::isSVNRepository($path)) { return true; } elseif (isset($options['verbose']) && $options['verbose'] == true) { if (!is_dir($path)) { print "'{$path}' is not a directory.\n"; } elseif (!USVN_SVNUtils::isSVNRepository($path)) { print "'{$path}' is not a SVN repository\n"; } } } elseif (isset($options['verbose']) && $options['verbose'] == true) { print "'{$path}' is not in subversion's path ({$config->subversion->path}).\n"; } return false; }
public function testCreateProjectWithoutGroupWithoutAdminButWithSvnDirectories() { $project = USVN_Project::createProject(array('projects_name' => 'InsertProjectOk', 'projects_start_date' => '1984-12-03 00:00:00'), "test", false, false, false, true); $table = new USVN_Db_Table_Projects(); $this->assertTrue($table->isAProject('InsertProjectOk'), "Le projet n'est pas cree"); $this->assertTrue(USVN_SVNUtils::isSVNRepository('tests/tmp/svn/InsertProjectOk'), "Le repository n'est pas cree"); $table = new USVN_Db_Table_Groups(); $this->assertFalse($table->isAGroup('InsertProjectOk'), "Le groupe est cree alors qu'il ne doit pas"); $this->assertFalse($project->userIsAdmin($this->_user)); $this->assertEquals(array(array('name' => 'branches', 'isDirectory' => true, 'path' => '/branches/'), array('name' => 'tags', 'isDirectory' => true, 'path' => '/tags/'), array('name' => 'trunk', 'isDirectory' => true, 'path' => '/trunk/')), USVN_SVNUtils::listSVN(Zend_Registry::get('config')->subversion->path . '/svn/InsertProjectOk', '/')); }