diff --git a/src/applications/search/controller/search/PhabricatorSearchController.php b/src/applications/search/controller/search/PhabricatorSearchController.php index 23456c2f85..754f150452 100644 --- a/src/applications/search/controller/search/PhabricatorSearchController.php +++ b/src/applications/search/controller/search/PhabricatorSearchController.php @@ -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); diff --git a/src/applications/search/controller/search/__init__.php b/src/applications/search/controller/search/__init__.php index a2fd9df50d..5e3ac55056 100644 --- a/src/applications/search/controller/search/__init__.php +++ b/src/applications/search/controller/search/__init__.php @@ -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');