/** * 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"); }
public function test_listFile() { USVN_SVNUtils::createSVN('tests/tmp/svn/test'); USVN_SVNUtils::createStandardDirectories('tests/tmp/svn/test'); USVN_SVNUtils::checkoutSvn('tests/tmp/svn/test', 'tests/tmp/out'); $path = getcwd(); chdir('tests/tmp/out'); mkdir('trunk/testdir'); `svn add trunk/testdir`; touch('trunk/testfile'); `svn add trunk/testfile`; `svn commit --non-interactive -m Test`; chdir($path); $svn = new USVN_SVN('test'); $res = $svn->listFile('/'); $this->assertEquals(3, count($res)); $this->assertContains(array("name" => "trunk", "isDirectory" => true, "path" => "/trunk/"), $res); $this->assertContains(array("name" => "branches", "isDirectory" => true, "path" => "/branches/"), $res); $this->assertContains(array("name" => "tags", "isDirectory" => true, "path" => "/tags/"), $res); $res = $svn->listFile('/trunk'); $this->assertEquals(2, count($res)); $this->assertContains(array("name" => "testdir", "isDirectory" => true, "path" => "/trunk/testdir/"), $res); $this->assertContains(array("name" => "testfile", "isDirectory" => false, "path" => "/trunk/testfile"), $res); }