Ejemplo n.º 1
0
 /**
  * Look after SVN repositories to import into USVN
  *
  * @param string $path
  * @param array $options array(recursive => true|false)
  * @todo allow to set n level of recursion in options
  * @throws USVN_Exception
  * @return array
  */
 public static function lookAfterSVNRepositoriesToImport($path, $options = array())
 {
     $results = array();
     if (USVN_ImportSVNRepositories::canBeImported($path, $options)) {
         return array($path);
     }
     $folders = USVN_DirectoryUtils::listDirectory($path);
     foreach ($folders as $folder) {
         $current_path = $path . DIRECTORY_SEPARATOR . $folder;
         if (USVN_ImportSVNRepositories::canBeImported($current_path, $options)) {
             $results[] = $current_path;
         } else {
             if (isset($options['recursive']) && $options['recursive'] == true) {
                 $results = array_merge($results, USVN_ImportSVNRepositories::lookAfterSVNRepositoriesToImport($current_path, $options));
             }
         }
     }
     return $results;
 }
Ejemplo n.º 2
0
    }
    Zend_Registry::set('config', $config);
    USVN_Translation::initTranslation($config->translation->locale, dirname(__FILE__) . "/../../app/locale");
    date_default_timezone_set($config->timezone);
    $db = Zend_Db::factory($config->database->adapterName, $config->database->options->toArray());
    USVN_Db_Table::$prefix = $config->database->prefix;
    Zend_Db_Table::setDefaultAdapter($db);
    Zend_Registry::set('config', $config);
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
    exit(1);
}
/**
 * Look for SVN repositories to import into USVN and finally perform the action
 */
$svnImport = new USVN_ImportSVNRepositories();
foreach ($paths as $path) {
    $tmp = $svnImport->lookAfterSVNRepositoriesToImport($path, $options);
    if (count($tmp)) {
        $repos = array_merge($repos, $tmp);
    } else {
        if ($options['verbose']) {
            print "No SVN repository here: {$path}\n";
        }
    }
}
//if we don't have any repository to import then die
if (!count($repos)) {
    print $usage;
    exit(1);
}
Ejemplo n.º 3
0
 public function testImportSVNRepositoriesOk()
 {
     try {
         $table = new USVN_Db_Table_Users();
         $obj = $table->fetchNew();
         $obj->setFromArray(array('users_login' => 'user_test', 'users_password' => 'password', 'users_firstname' => 'firstname', 'users_lastname' => 'lastname', 'users_email' => '*****@*****.**'));
         $obj->save();
     } catch (USVN_Exception $e) {
         print $e->getMessage() . "\n";
         $this->fail();
     }
     $path = 'tests/tmp/svn/test/';
     mkdir($path);
     USVN_SVNUtils::createSvn($path . 'test');
     USVN_SVNUtils::createSvn($path . 'test2');
     mkdir($path . 'test3');
     USVN_SVNUtils::createSvn($path . 'test3/test3');
     $options = array('recursive' => true, 'login' => 'user_test');
     $imp = new USVN_ImportSVNRepositories();
     $results = $imp->lookAfterSVNRepositoriesToImport($path, $options);
     if (count($results) != 3) {
         $this->fail();
     }
     $imp->addSVNRepositoriesToImport($results, $options);
     try {
         $imp->importSVNRepositories();
     } catch (USVN_Exception $e) {
         print $e->getMessage() . "\n";
         $this->fail();
     }
     USVN_DirectoryUtils::removeDirectory($path);
 }