本文整理汇总了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));
}
}