Allow excluding paths from package

Summary: Resolves T2149.

Test Plan:
  $ bin/storage upgrade

# /owners/ - saw +
# /owners/package/1/ - saw +
# /owners/edit/1/ - added exclude paths, saw correct e-mail
# /rPabc123 - included paths are still highlighted and excluded not
# /owners/view/search/?path=/included/ - found
# /owners/view/search/?path=/excluded/ - not found
# owners.query - path: /included/
# owners.query - path: /excluded/
# new unit test

  PhabricatorOwnersPackage::loadAffectedPackages(
    $repository,
    array('/excluded/b.php'));

  PhabricatorOwnersPackage::loadAffectedPackages(
    $repository,
    array('/included/a.php'));

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2149

Differential Revision: https://secure.phabricator.com/D4102
This commit is contained in:
vrana
2012-12-06 17:23:56 -08:00
parent bf9bc885b7
commit 4f615ad2a9
15 changed files with 156 additions and 48 deletions

View File

@@ -34,6 +34,7 @@ final class PhabricatorOwnersListController
$where = array('1 = 1');
$join = array();
$having = '';
if ($request->getStr('name')) {
$where[] = qsprintf(
@@ -59,10 +60,14 @@ final class PhabricatorOwnersListController
if ($request->getStr('path')) {
$where[] = qsprintf(
$conn_r,
'path.path LIKE %~ OR %s LIKE CONCAT(path.path, %s)',
'(path.path LIKE %~ AND NOT path.excluded) OR
%s LIKE CONCAT(REPLACE(path.path, %s, %s), %s)',
$request->getStr('path'),
$request->getStr('path'),
'_',
'\_',
'%');
$having = 'HAVING MAX(path.excluded) = 0';
}
}
@@ -80,10 +85,11 @@ final class PhabricatorOwnersListController
$data = queryfx_all(
$conn_r,
'SELECT p.* FROM %T p %Q WHERE %Q GROUP BY p.id',
'SELECT p.* FROM %T p %Q WHERE %Q GROUP BY p.id %Q',
$package->getTableName(),
implode(' ', $join),
'('.implode(') AND (', $where).')');
'('.implode(') AND (', $where).')',
$having);
$packages = $package->loadAllFromArray($data);
$header = 'Search Results';
@@ -254,6 +260,7 @@ final class PhabricatorOwnersListController
'action' => 'browse',
));
$pkg_paths[$key] =
($path->getExcluded() ? '–' : '+').' '.
'<strong>'.phutil_escape_html($repo->getName()).'</strong> '.
phutil_render_tag(
'a',