本文整理汇总了PHP中GitRepository::isNameValid方法的典型用法代码示例。如果您正苦于以下问题:PHP GitRepository::isNameValid方法的具体用法?PHP GitRepository::isNameValid怎么用?PHP GitRepository::isNameValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitRepository
的用法示例。
在下文中一共展示了GitRepository::isNameValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cloneRepository
public function cloneRepository($projectId, $forkName, $parentId)
{
$c = $this->getController();
$projectId = intval($projectId);
$parentId = intval($parentId);
if (empty($projectId) || empty($forkName) || empty($parentId)) {
$c->addError($this->getText('actions_params_error'));
return false;
}
$parentRepo = new GitRepository();
$parentRepo->setId($parentId);
try {
$parentRepo->load();
// Disable possibility to delete gitolite repositories
if ($parentRepo->getBackend() instanceof Git_Backend_Gitolite) {
$c->addError($this->getText('disable_fork_gitolite'));
$c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
}
if ($parentRepo->isNameValid($forkName) === false) {
$c->addError($this->getText('actions_input_format_error', array($parentRepo->getBackend()->getAllowedCharsInNamePattern(), GitDao::REPO_NAME_MAX_LENGTH)));
$c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
return false;
}
if (!$parentRepo->isInitialized()) {
$c->addError($this->getText('repo_not_initialized'));
$c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
return false;
}
} catch (GitDaoException $e) {
$c->addError($e->getMessage());
$c->redirect('/plugins/git/?action=index&group_id=' . $projectId);
return false;
}
$this->systemEventManager->createEvent('GIT_REPO_CLONE', $projectId . SystemEvent::PARAMETER_SEPARATOR . $forkName . SystemEvent::PARAMETER_SEPARATOR . $parentId . SystemEvent::PARAMETER_SEPARATOR . $this->user->getId(), SystemEvent::PRIORITY_MEDIUM);
$c->addInfo($this->getText('actions_create_repo_process'));
$c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
return;
}
示例2: checkNameValidation
private function checkNameValidation(GitRepository $repo)
{
$this->assertFalse($repo->isNameValid(''));
$this->assertFalse($repo->isNameValid('/'));
$this->assertFalse($repo->isNameValid('/jambon'));
$this->assertFalse($repo->isNameValid('jambon/'));
$this->assertTrue($repo->isNameValid('jambon'));
$this->assertTrue($repo->isNameValid('jambon.beurre'));
$this->assertTrue($repo->isNameValid('jambon-beurre'));
$this->assertTrue($repo->isNameValid('jambon_beurre'));
$this->assertFalse($repo->isNameValid('jambon/.beurre'));
$this->assertFalse($repo->isNameValid('jambon..beurre'));
$this->assertFalse($repo->isNameValid('jambon...beurre'));
$this->assertFalse($repo->isNameValid(str_pad('name_with_more_than_255_chars_', 256, '_')));
$this->assertFalse($repo->isNameValid('repo.git'));
$this->assertFalse($repo->isNameValid('u/toto'));
}
示例3: isNamespaceValid
private function isNamespaceValid(GitRepository $repository, $namespace)
{
if ($namespace) {
$ns_chunk = explode('/', $namespace);
foreach ($ns_chunk as $chunk) {
if (!$repository->isNameValid($chunk)) {
throw new Exception($GLOBALS['Language']->getText('plugin_git', 'fork_repository_invalid_namespace'));
}
}
}
return true;
}