# HG changeset patch # User FUJIWARA Katsunori # Date 1485770985 -32400 # Node ID 8df1e9edd68fa05ed1d574835d7f9599165a07a6 # Parent de37fcbce8c5fd0a5eabe28d766fc6b555d202ee indexers: use correct full repository name, which contains group name, at indexing Before this revision, searching under the specific repository could cause unexpected result, because repository names used for indexing didn't contain the group name. This issue was introduced by 8b7c0ef62427, which uses repo.name_unicode as repository name instead of safe_unicode(repo_name) to reduce unicode conversion cost while repetition at indexing. To use correct repository name at indexing, this revision replaces repo.name_unicode by safe_unicode(repo_name). Reducing cost of repeated unicode conversion cost while will (and should) be addressed in the future. This revision also adds a comment to BaseRepository.name property, to avoid similar misunderstandings in the future. diff -r de37fcbce8c5 -r 8df1e9edd68f kallithea/lib/indexers/daemon.py --- a/kallithea/lib/indexers/daemon.py Mon Jan 23 20:54:42 2017 +0100 +++ b/kallithea/lib/indexers/daemon.py Mon Jan 30 19:09:45 2017 +0900 @@ -203,7 +203,7 @@ writer.add_document( fileid=p, owner=unicode(repo.contact), - repository_rawname=repo.name_unicode, + repository_rawname=safe_unicode(repo_name), repository=safe_unicode(repo_name), path=p, content=u_content, @@ -242,7 +242,7 @@ raw_id=unicode(cs.raw_id), owner=unicode(repo.contact), date=cs._timestamp, - repository_rawname=repo.name_unicode, + repository_rawname=safe_unicode(repo_name), repository=safe_unicode(repo_name), author=cs.author, message=cs.message, diff -r de37fcbce8c5 -r 8df1e9edd68f kallithea/lib/vcs/backends/base.py --- a/kallithea/lib/vcs/backends/base.py Mon Jan 23 20:54:42 2017 +0100 +++ b/kallithea/lib/vcs/backends/base.py Mon Jan 30 19:09:45 2017 +0900 @@ -97,6 +97,9 @@ @LazyProperty def name(self): + """ + Return repository name (without group name) + """ raise NotImplementedError @property diff -r de37fcbce8c5 -r 8df1e9edd68f kallithea/tests/functional/test_search_indexing.py --- a/kallithea/tests/functional/test_search_indexing.py Mon Jan 23 20:54:42 2017 +0100 +++ b/kallithea/tests/functional/test_search_indexing.py Mon Jan 30 19:09:45 2017 +0900 @@ -125,6 +125,25 @@ {'q': q, 'type': searchtype}) response.mustcontain('>%d results' % hit) + @parametrize('reponame', [ + (u'indexing_test'), + (u'indexing_test-fork'), + (u'group/indexing_test'), + (u'this-is-it'), + ]) + @parametrize('searchtype,query,hit', [ + ('content', 'this_should_be_unique_content', 1), + ('commit', 'this_should_be_unique_commit_log', 1), + ('path', 'this_should_be_unique_filename.txt', 1), + ]) + def test_searching_under_repository(self, reponame, searchtype, query, hit): + self.log_user() + + response = self.app.get(url(controller='search', action='index', + repo_name=reponame), + {'q': query, 'type': searchtype}) + response.mustcontain('>%d results' % hit) + @parametrize('searchtype,query,hit', [ ('content', 'this_should_be_unique_content', 1), ('commit', 'this_should_be_unique_commit_log', 1),