@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow repository short names to be used as identifiers

Summary:
Ref T4245. This allows `bin/repository update bread` to work, in addition to `rBREAD`, `R123`, `123`, `BREAD`, etc., if a repository has a short name set.

This primarily affects CLI commands (like `bin/repository`) and Conduit API calls. It has no normal user-facing impact.

Test Plan: Ran `bin/repository update bread` and such.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14988

+50 -9
+50 -9
src/applications/repository/query/PhabricatorRepositoryQuery.php
··· 17 17 private $callsignIdentifiers; 18 18 private $phidIdentifiers; 19 19 private $monogramIdentifiers; 20 + private $slugIdentifiers; 20 21 21 22 private $identifierMap; 22 23 ··· 56 57 $callsigns = array(); 57 58 $phids = array(); 58 59 $monograms = array(); 60 + $slugs = array(); 59 61 60 62 foreach ($identifiers as $identifier) { 61 63 if (ctype_digit((string)$identifier)) { 62 64 $ids[$identifier] = $identifier; 63 - } else if (preg_match('/^(r[A-Z]+)|(R[1-9]\d*)\z/', $identifier)) { 65 + continue; 66 + } 67 + 68 + if (preg_match('/^(r[A-Z]+)|(R[1-9]\d*)\z/', $identifier)) { 64 69 $monograms[$identifier] = $identifier; 65 - } else { 66 - $repository_type = PhabricatorRepositoryRepositoryPHIDType::TYPECONST; 67 - if (phid_get_type($identifier) === $repository_type) { 68 - $phids[$identifier] = $identifier; 69 - } else { 70 - $callsigns[$identifier] = $identifier; 71 - } 70 + continue; 72 71 } 72 + 73 + $repository_type = PhabricatorRepositoryRepositoryPHIDType::TYPECONST; 74 + if (phid_get_type($identifier) === $repository_type) { 75 + $phids[$identifier] = $identifier; 76 + continue; 77 + } 78 + 79 + if (preg_match('/^[A-Z]+\z/', $identifier)) { 80 + $callsigns[$identifier] = $identifier; 81 + continue; 82 + } 83 + 84 + $slugs[$identifier] = $identifier; 73 85 } 74 86 75 87 $this->numericIdentifiers = $ids; 76 88 $this->callsignIdentifiers = $callsigns; 77 89 $this->phidIdentifiers = $phids; 78 90 $this->monogramIdentifiers = $monograms; 91 + $this->slugIdentifiers = $slugs; 79 92 80 93 return $this; 81 94 } ··· 305 318 } 306 319 } 307 320 321 + if ($this->slugIdentifiers) { 322 + $slug_map = array(); 323 + foreach ($repositories as $repository) { 324 + $slug = $repository->getRepositorySlug(); 325 + if ($slug === null) { 326 + continue; 327 + } 328 + 329 + $normal = phutil_utf8_strtolower($slug); 330 + $slug_map[$normal] = $repository; 331 + } 332 + 333 + foreach ($this->slugIdentifiers as $slug) { 334 + $normal = phutil_utf8_strtolower($slug); 335 + if (isset($slug_map[$normal])) { 336 + $this->identifierMap[$slug] = $slug_map[$normal]; 337 + } 338 + } 339 + } 340 + 308 341 return $repositories; 309 342 } 310 343 ··· 480 513 if ($this->numericIdentifiers || 481 514 $this->callsignIdentifiers || 482 515 $this->phidIdentifiers || 483 - $this->monogramIdentifiers) { 516 + $this->monogramIdentifiers || 517 + $this->slugIdentifiers) { 484 518 $identifier_clause = array(); 485 519 486 520 if ($this->numericIdentifiers) { ··· 529 563 'r.callsign IN (%Ls)', 530 564 $monogram_callsigns); 531 565 } 566 + } 567 + 568 + if ($this->slugIdentifiers) { 569 + $identifier_clause[] = qsprintf( 570 + $conn, 571 + 'r.repositorySlug IN (%Ls)', 572 + $this->slugIdentifiers); 532 573 } 533 574 534 575 $where = array('('.implode(' OR ', $identifier_clause).')');