Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15343174
D14943.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D14943.id.diff
View Options
diff --git a/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php
--- a/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php
@@ -44,7 +44,6 @@
$commit,
$path);
-
$lines = id(new LinesOfALargeExecFuture($future))->setDelimiter("\0");
return $this->filterResults($lines, $request);
}
@@ -86,16 +85,15 @@
$results = array();
$count = 0;
foreach ($lines as $line) {
- if (!$pattern || preg_match($pattern, $line)) {
- if ($count >= $offset) {
- $results[] = $line;
- }
+ if (strlen($pattern) && !preg_match($pattern, $line)) {
+ continue;
+ }
- $count++;
+ $results[] = $line;
+ $count++;
- if ($limit && ($count >= ($offset + $limit))) {
- break;
- }
+ if ($limit && ($count >= ($offset + $limit))) {
+ break;
}
}
diff --git a/src/applications/diffusion/conduit/DiffusionSearchQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionSearchQueryConduitAPIMethod.php
--- a/src/applications/diffusion/conduit/DiffusionSearchQueryConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionSearchQueryConduitAPIMethod.php
@@ -25,18 +25,19 @@
);
}
- protected function defineCustomErrorTypes() {
- return array(
- 'ERR-GREP-COMMAND' => pht('Grep command failed.'),
- );
- }
-
protected function getResult(ConduitAPIRequest $request) {
try {
$results = parent::getResult($request);
} catch (CommandException $ex) {
- throw id(new ConduitException('ERR-GREP-COMMAND'))
- ->setErrorDescription($ex->getStderr());
+ $err = $ex->getError();
+
+ if ($err === 1) {
+ // `git grep` and `hg grep` exit with 1 if there are no matches;
+ // assume we just didn't get any hits.
+ return array();
+ }
+
+ throw $ex;
}
$offset = $request->getValue('offset');
@@ -63,6 +64,7 @@
$binary_pattern = '/Binary file [^:]*:(.+) matches/';
$lines = new LinesOfALargeExecFuture($future);
+
foreach ($lines as $line) {
$result = null;
if (preg_match('/[^:]*:(.+)\0(.+)\0(.*)/', $line, $result)) {
diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php
--- a/src/applications/diffusion/controller/DiffusionBrowseController.php
+++ b/src/applications/diffusion/controller/DiffusionBrowseController.php
@@ -351,19 +351,16 @@
}
private function renderSearchResults() {
+ $request = $this->getRequest();
+
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$results = array();
- $limit = 100;
- $page = $this->getRequest()->getInt('page', 0);
- $pager = new PHUIPagerView();
- $pager->setPageSize($limit);
- $pager->setOffset($page);
- $pager->setURI($this->getRequest()->getRequestURI(), 'page');
+ $pager = id(new PHUIPagerView())
+ ->readFromRequest($request);
$search_mode = null;
-
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$results = array();
@@ -371,32 +368,31 @@
default:
if (strlen($this->getRequest()->getStr('grep'))) {
$search_mode = 'grep';
- $query_string = $this->getRequest()->getStr('grep');
+ $query_string = $request->getStr('grep');
$results = $this->callConduitWithDiffusionRequest(
'diffusion.searchquery',
array(
'grep' => $query_string,
'commit' => $drequest->getStableCommit(),
'path' => $drequest->getPath(),
- 'limit' => $limit + 1,
- 'offset' => $page,
+ 'limit' => $pager->getPageSize() + 1,
+ 'offset' => $pager->getOffset(),
));
} else { // Filename search.
$search_mode = 'find';
- $query_string = $this->getRequest()->getStr('find');
+ $query_string = $request->getStr('find');
$results = $this->callConduitWithDiffusionRequest(
'diffusion.querypaths',
array(
'pattern' => $query_string,
'commit' => $drequest->getStableCommit(),
'path' => $drequest->getPath(),
- 'limit' => $limit + 1,
- 'offset' => $page,
+ 'limit' => $pager->getPageSize() + 1,
+ 'offset' => $pager->getOffset(),
));
}
break;
}
-
$results = $pager->sliceResults($results);
if ($search_mode == 'grep') {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 10, 10:14 PM (1 d, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7475849
Default Alt Text
D14943.id.diff (4 KB)
Attached To
Mode
D14943: Return no results from `grep` repository queries on error
Attached
Detach File
Event Timeline
Log In to Comment