aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorDavid Svantesson <davidsvantesson@gmail.com>2019-08-23 04:37:35 +0200
committertechknowlogick <techknowlogick@gitea.io>2019-08-22 22:37:35 -0400
commitca6fb004ac50fc924861112403895d637c6a2d1d (patch)
treedd8b626cf07212142a32e1eae388662f4b882196 /models
parent4ea9a377db86e4b78d9be2f5d481f69a06c78856 (diff)
downloadgitea-ca6fb004ac50fc924861112403895d637c6a2d1d.tar.gz
gitea-ca6fb004ac50fc924861112403895d637c6a2d1d.zip
Change repo search to use exact match for topic search. (#7941)
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/repo_list.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/models/repo_list.go b/models/repo_list.go
index 7460c4b0ed..ee4266d4e6 100644
--- a/models/repo_list.go
+++ b/models/repo_list.go
@@ -248,7 +248,11 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err
// separate keyword
var subQueryCond = builder.NewCond()
for _, v := range strings.Split(opts.Keyword, ",") {
- subQueryCond = subQueryCond.Or(builder.Like{"topic.name", strings.ToLower(v)})
+ if opts.TopicOnly {
+ subQueryCond = subQueryCond.Or(builder.Eq{"topic.name": strings.ToLower(v)})
+ } else {
+ subQueryCond = subQueryCond.Or(builder.Like{"topic.name", strings.ToLower(v)})
+ }
}
subQuery := builder.Select("repo_topic.repo_id").From("repo_topic").
Join("INNER", "topic", "topic.id = repo_topic.topic_id").