1
0
Fork 0
forked from forgejo/forgejo

Move issues related files into models/issues (#19931)

* Move access and repo permission to models/perm/access

* fix test

* fix git test

* Move functions sequence

* Some improvements per @KN4CK3R and @delvh

* Move issues related code to models/issues

* Move some issues related sub package

* Merge

* Fix test

* Fix test

* Fix test

* Fix test

* Rename some files
This commit is contained in:
Lunny Xiao 2022-06-13 17:37:59 +08:00 committed by GitHub
parent 3708ca8e28
commit 1a9821f57a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
180 changed files with 3667 additions and 3677 deletions

View file

@ -20,9 +20,9 @@ import (
"strings"
"time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues"
pull_model "code.gitea.io/gitea/models/pull"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/analyze"
@ -82,7 +82,7 @@ type DiffLine struct {
Match int
Type DiffLineType
Content string
Comments []*models.Comment
Comments []*issues_model.Comment
SectionInfo *DiffLineSectionInfo
}
@ -704,8 +704,8 @@ type Diff struct {
}
// LoadComments loads comments into each line
func (diff *Diff) LoadComments(ctx context.Context, issue *models.Issue, currentUser *user_model.User) error {
allComments, err := models.FetchCodeComments(ctx, issue, currentUser)
func (diff *Diff) LoadComments(ctx context.Context, issue *issues_model.Issue, currentUser *user_model.User) error {
allComments, err := issues_model.FetchCodeComments(ctx, issue, currentUser)
if err != nil {
return err
}
@ -1520,7 +1520,7 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
// SyncAndGetUserSpecificDiff is like GetDiff, except that user specific data such as which files the given user has already viewed on the given PR will also be set
// Additionally, the database asynchronously is updated if files have changed since the last review
func SyncAndGetUserSpecificDiff(ctx context.Context, userID int64, pull *models.PullRequest, gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff, error) {
func SyncAndGetUserSpecificDiff(ctx context.Context, userID int64, pull *issues_model.PullRequest, gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff, error) {
diff, err := GetDiff(gitRepo, opts, files...)
if err != nil {
return nil, err
@ -1583,7 +1583,7 @@ outer:
}
// CommentAsDiff returns c.Patch as *Diff
func CommentAsDiff(c *models.Comment) (*Diff, error) {
func CommentAsDiff(c *issues_model.Comment) (*Diff, error) {
diff, err := ParsePatch(setting.Git.MaxGitDiffLines,
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(c.Patch), "")
if err != nil {
@ -1601,7 +1601,7 @@ func CommentAsDiff(c *models.Comment) (*Diff, error) {
}
// CommentMustAsDiff executes AsDiff and logs the error instead of returning
func CommentMustAsDiff(c *models.Comment) *Diff {
func CommentMustAsDiff(c *issues_model.Comment) *Diff {
if c == nil {
return nil
}