You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/16 20:53:17 UTC
[2/3] git commit: [#6192] ticket:335 Add --project-regex option to
ReindexCommand
[#6192] ticket:335 Add --project-regex option to ReindexCommand
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/74dfc196
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/74dfc196
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/74dfc196
Branch: refs/heads/master
Commit: 74dfc19607d969046edd0247cc26350b15e345f9
Parents: 94ee729
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue May 7 07:32:34 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 16 18:44:24 2013 +0000
----------------------------------------------------------------------
Allura/allura/command/show_models.py | 5 +++++
Allura/allura/tests/test_commands.py | 7 +++++++
2 files changed, 12 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/74dfc196/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index ef8767f..17d4b7f 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -52,6 +52,9 @@ class ReindexCommand(base.Command):
parser = base.Command.standard_parser(verbose=True)
parser.add_option('-p', '--project', dest='project', default=None,
help='project to reindex')
+ parser.add_option('--project-regex', dest='project_regex', default='',
+ help='Restrict reindex to projects for which the shortname matches '
+ 'the provided regex.')
parser.add_option('-n', '--neighborhood', dest='neighborhood', default=None,
help='neighborhood to reindex (e.g. p)')
@@ -72,6 +75,8 @@ class ReindexCommand(base.Command):
graph = build_model_inheritance_graph()
if self.options.project:
q_project = dict(shortname=self.options.project)
+ elif self.options.project_regex:
+ q_project = dict(shortname={'$regex': self.options.project_regex})
elif self.options.neighborhood:
neighborhood_id = M.Neighborhood.query.get(
url_prefix='/%s/' % self.options.neighborhood)._id
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/74dfc196/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index 8a1463f..bfaf350 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -350,3 +350,10 @@ class TestReindexCommand(object):
g.solr.delete.reset_mock()
cmd.run([test_config, '-p', 'test', '--solr', '--skip-solr-delete'])
assert not g.solr.delete.called, 'solr.delete() must not be called'
+
+ @patch('allura.command.show_models.utils')
+ def test_project_regex(self, utils):
+ cmd = show_models.ReindexCommand('reindex')
+ cmd.run([test_config, '--project-regex', '^test'])
+ utils.chunked_find.assert_called_once_with(
+ M.Project, {'shortname': {'$regex': '^test'}})