Skip to content

Commit d12ea5f

Browse files
committed
Add const for 'scope-' prefix.
1 parent 8da23e7 commit d12ea5f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

models/issues/issue_search.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"xorm.io/xorm"
2222
)
2323

24+
const ScopeSortPrefix = "scope-"
25+
2426
// IssuesOptions represents options of an issue.
2527
type IssuesOptions struct { //nolint
2628
Paginator *db.ListOptions
@@ -71,8 +73,8 @@ func (o *IssuesOptions) Copy(edit ...func(options *IssuesOptions)) *IssuesOption
7173
// sortType string
7274
func applySorts(sess *xorm.Session, sortType string, priorityRepoID int64) {
7375
// Since this sortType is dynamically created, it has to be treated specially.
74-
if strings.HasPrefix(sortType, "scope-") {
75-
scope := strings.TrimPrefix(sortType, "scope-")
76+
if strings.HasPrefix(sortType, ScopeSortPrefix) {
77+
scope := strings.TrimPrefix(sortType, ScopeSortPrefix)
7678
sess.Join("LEFT", "issue_label", "issue.id = issue_label.issue_id")
7779
sess.Join("LEFT", "label", "label.id = issue_label.label_id and label.name LIKE ?", scope+"/%")
7880
sess.Asc("label.exclusive_order").Desc("issue.id")

routers/web/user/setting/applications.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
auth_model "code.gitea.io/gitea/models/auth"
1212
"code.gitea.io/gitea/models/db"
13+
issues_model "code.gitea.io/gitea/models/issues"
1314
user_model "code.gitea.io/gitea/models/user"
1415
"code.gitea.io/gitea/modules/setting"
1516
"code.gitea.io/gitea/modules/templates"
@@ -44,7 +45,7 @@ func ApplicationsPost(ctx *context.Context) {
4445
_ = ctx.Req.ParseForm()
4546
var scopeNames []string
4647
for k, v := range ctx.Req.Form {
47-
if strings.HasPrefix(k, "scope-") {
48+
if strings.HasPrefix(k, issues_model.ScopeSortPrefix) {
4849
scopeNames = append(scopeNames, v...)
4950
}
5051
}

0 commit comments

Comments
 (0)