Пример #1
0
 /**
  * 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);
     }
 }
Пример #2
0
 protected function setUp()
 {
     parent::setUp();
     mkdir('tests/fakehome');
     chmod('tests/fakehome', 00);
     putenv('HOME=tests/fakehome');
     $this->_saveHOME = getenv("HOME");
     USVN_SVNUtils::createSvn('tests/tmp/svn directory');
     USVN_SVNUtils::createStandardDirectories('tests/tmp/svn directory');
     USVN_SVNUtils::checkoutSvn('tests/tmp/svn directory', 'tests/tmp/out');
     file_put_contents('tests/tmp/svn directory/hooks/pre-revprop-change.bat', "@ECHO OFF\r\n");
     file_put_contents('tests/tmp/svn directory/hooks/pre-revprop-change', "#!/bin/sh\nexit 0");
     chmod('tests/tmp/svn directory/hooks/pre-revprop-change', 0700);
     $path = getcwd();
     chdir('tests/tmp/out');
     mkdir('trunk/testdir');
     `svn add trunk/testdir`;
     touch('trunk/testfile');
     `svn add trunk/testfile`;
     `svn commit --non-interactive --username toto -m Test`;
     touch('trunk/testfile2');
     `svn add trunk/testfile2`;
     `svn commit --non-interactive --username tutu -m Test2`;
     `svn propset svn:date --revprop -r3 "1984-12-03T01:02:03.218987Z" .`;
     chdir($path);
 }
Пример #3
0
 /**
  * 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);
     }
 }
Пример #4
0
 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);
 }