本文整理匯總了PHP中PhabricatorRepository::isValidRepositorySlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhabricatorRepository::isValidRepositorySlug方法的具體用法?PHP PhabricatorRepository::isValidRepositorySlug怎麽用?PHP PhabricatorRepository::isValidRepositorySlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhabricatorRepository
的用法示例。
在下文中一共展示了PhabricatorRepository::isValidRepositorySlug方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testRepositoryShortNameValidation
public function testRepositoryShortNameValidation()
{
$good = array('sensible-repository', 'AReasonableName', 'ACRONYM-project', 'sol-123', '46-helixes', 'node.io', 'internet.com', 'www.internet-site.com.repository', 'with_under-scores', 'A-_._-_._-_._-_._-_._-_._-1', str_repeat('a', 64));
$poor = array('', '1', '.', '-_-', 'AAAA', '..', 'a/b', '../../etc/passwd', '/', '!', '@', 'ca$hmoney', 'repo with spaces', 'hyphen-', '-ated', '_underscores_', 'yes!', 'quack.git', 'git.git', '.git.git.git', str_repeat('a', 65));
foreach ($good as $nice_name) {
$actual = PhabricatorRepository::isValidRepositorySlug($nice_name);
$this->assertEqual(true, $actual, pht('Expected "%s" to be a valid repository short name.', $nice_name));
}
foreach ($poor as $poor_name) {
$actual = PhabricatorRepository::isValidRepositorySlug($poor_name);
$this->assertEqual(false, $actual, pht('Expected "%s" to be rejected as an invalid repository ' . 'short name.', $poor_name));
}
}
示例2: PhabricatorRepository
<?php
$table = new PhabricatorRepository();
$conn_w = $table->establishConnection('w');
foreach (new LiskMigrationIterator($table) as $repository) {
$slug = $repository->getRepositorySlug();
if ($slug !== null) {
continue;
}
$clone_name = $repository->getDetail('clone-name');
if (!strlen($clone_name)) {
continue;
}
if (!PhabricatorRepository::isValidRepositorySlug($clone_name)) {
echo tsprintf("%s\n", pht('Repository "%s" has a "Clone/Checkout As" name which is no longer ' . 'valid ("%s"). You can edit the repository to give it a new, valid ' . 'short name.', $repository->getDisplayName(), $clone_name));
continue;
}
try {
queryfx($conn_w, 'UPDATE %T SET repositorySlug = %s WHERE id = %d', $table->getTableName(), $clone_name, $repository->getID());
} catch (AphrontDuplicateKeyQueryException $ex) {
echo tsprintf("%s\n", pht('Repository "%s" has a duplicate "Clone/Checkout As" name ("%s"). ' . 'Each name must now be unique. You can edit the repository to give ' . 'it a new, unique short name.', $repository->getDisplayName(), $clone_name));
}
}