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));
     }
 }
<?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));
    }
}