1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Display object shortcuts in search results

Summary: Search for D1234 currently finds everything but revision 1234.

Test Plan:
Search for:

- rX
- rX1234 under SVN
- rXabcd under GIT
- D1234
- T4

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2081
This commit is contained in:
vrana 2012-04-02 17:29:52 -07:00
parent be3c179561
commit 021c1b5a05
2 changed files with 39 additions and 0 deletions

View file

@ -230,6 +230,41 @@ final class PhabricatorSearchController
$results = $pager->sliceResults($results);
if (!$request->getInt('page')) {
$jump = null;
$query_str = $query->getQuery();
$match = null;
if (preg_match('/^r([A-Z]+)(\S*)$/', $query_str, $match)) {
$repository = id(new PhabricatorRepository())
->loadOneWhere('callsign = %s', $match[1]);
if ($match[2] == '') {
$jump = $repository;
} elseif ($repository) {
$jump = id(new PhabricatorRepositoryCommit())->loadOneWhere(
'repositoryID = %d AND commitIdentifier = %s',
$repository->getID(),
$match[2]);
if (!$jump) {
try {
$jump = id(new PhabricatorRepositoryCommit())->loadOneWhere(
'repositoryID = %d AND commitIdentifier LIKE %>',
$repository->getID(),
$match[2]);
} catch (AphrontQueryCountException $ex) {
// Ambiguous, no jump.
}
}
}
} elseif (preg_match('/^d(\d+)$/i', $query_str, $match)) {
$jump = id(new DifferentialRevision())->load($match[1]);
} elseif (preg_match('/^t(\d+)$/i', $query_str, $match)) {
$jump = id(new ManiphestTask())->load($match[1]);
}
if ($jump) {
array_unshift($results, $jump->getPHID());
}
}
if ($results) {
$loader = new PhabricatorObjectHandleData($results);

View file

@ -8,9 +8,13 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/differential/storage/revision');
phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/people/storage/preferences');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/repository/storage/commit');
phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'applications/search/constants/scope');
phutil_require_module('phabricator', 'applications/search/controller/base');
phutil_require_module('phabricator', 'applications/search/engine/jumpnav');