Exemplo n.º 1
0
 public function createRepo(ServiceSvn $service, HTTPRequest $request)
 {
     $token = $this->generateTokenForCeateRepository($request->getProject());
     $token->check();
     $rule = new RuleName($request->getProject(), new DAO());
     $repo_name = $request->get("repo_name");
     if (!$rule->isValid($repo_name)) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_svn_manage_repository', 'invalid_name'));
         $GLOBALS['Response']->addFeedback('error', $rule->getErrorMessage());
         $GLOBALS['Response']->redirect(SVN_BASE_URL . '/?' . http_build_query(array('group_id' => $request->getProject()->getid(), 'name' => $repo_name)));
     } else {
         $repository_to_create = new Repository("", $repo_name, $request->getProject());
         try {
             $this->repository_manager->create($repository_to_create);
             $repo_event['path'] = $repository_to_create->getPath();
             $repo_event['project_id'] = $request->getProject()->getId();
             $repo_event['name'] = $request->getProject()->getUnixNameMixedCase() . "/" . $repository_to_create->getName();
             $this->system_event_manager->createEvent('Tuleap\\Svn\\EventRepository\\' . SystemEvent_SVN_CREATE_REPOSITORY::NAME, implode(SystemEvent::PARAMETER_SEPARATOR, $repo_event), SystemEvent::PRIORITY_HIGH);
             $GLOBALS['Response']->addFeedback('info', $repo_name . ' ' . $GLOBALS['Language']->getText('plugin_svn_manage_repository', 'update_success'));
             $GLOBALS['Response']->redirect(SVN_BASE_URL . '/?' . http_build_query(array('group_id' => $request->getProject()->getid())));
         } catch (CannotCreateRepositoryException $e) {
             $GLOBALS['Response']->addFeedback('error', $repo_name . ' ' . $GLOBALS['Language']->getText('plugin_svn', 'update_error'));
             $GLOBALS['Response']->redirect(SVN_BASE_URL . '/?' . http_build_query(array('group_id' => $request->getProject()->getid(), 'name' => $repo_name)));
         }
     }
 }
Exemplo n.º 2
0
 public function itForbidsBeginnigByAChar()
 {
     $rule = new RuleName();
     $this->assertFalse($rule->isValid("1"));
     $this->assertFalse($rule->isValid("1deux"));
     $this->assertTrue($rule->isValid("a1b"));
 }