Skip to content

Commit 172178c

Browse files
committed
merge the code owner file list
1 parent f0dd070 commit 172178c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

routers/web/repo/view_file.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"image"
1010
"io"
1111
"path"
12-
"slices"
1312
"strings"
1413

1514
git_model "code.gitea.io/gitea/models/git"
@@ -79,7 +78,7 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) {
7978
if workFlowErr != nil {
8079
ctx.Data["FileError"] = ctx.Locale.Tr("actions.runs.invalid_workflow_helper", workFlowErr.Error())
8180
}
82-
} else if slices.Contains([]string{"CODEOWNERS", "docs/CODEOWNERS", ".gitea/CODEOWNERS"}, ctx.Repo.TreePath) {
81+
} else if issue_service.IsCodeOwnerFile(ctx.Repo.TreePath) {
8382
if data, err := blob.GetBlobContent(setting.UI.MaxDisplayFileSize); err == nil {
8483
_, warnings := issue_model.GetCodeOwnersFromContent(ctx, data)
8584
if len(warnings) > 0 {

services/issue/pull.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package issue
66
import (
77
"context"
88
"fmt"
9+
"slices"
910
"time"
1011

1112
issues_model "code.gitea.io/gitea/models/issues"
@@ -40,6 +41,12 @@ type ReviewRequestNotifier struct {
4041
ReviewTeam *org_model.Team
4142
}
4243

44+
var codeOwnerFiles = []string{"CODEOWNERS", "docs/CODEOWNERS", ".gitea/CODEOWNERS"}
45+
46+
func IsCodeOwnerFile(f string) bool {
47+
return slices.Contains(codeOwnerFiles, f)
48+
}
49+
4350
func PullRequestCodeOwnersReview(ctx context.Context, pr *issues_model.PullRequest) ([]*ReviewRequestNotifier, error) {
4451
if err := pr.LoadIssue(ctx); err != nil {
4552
return nil, err
@@ -71,8 +78,8 @@ func PullRequestCodeOwnersReview(ctx context.Context, pr *issues_model.PullReque
7178
}
7279

7380
var data string
74-
files := []string{"CODEOWNERS", "docs/CODEOWNERS", ".gitea/CODEOWNERS"}
75-
for _, file := range files {
81+
82+
for _, file := range codeOwnerFiles {
7683
if blob, err := commit.GetBlobByPath(file); err == nil {
7784
data, err = blob.GetBlobContent(setting.UI.MaxDisplayFileSize)
7885
if err == nil {

0 commit comments

Comments
 (0)