aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/editor.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-24 15:56:24 +0800
committerGitHub <noreply@github.com>2021-11-24 15:56:24 +0800
commitc97d66d23cf14e88514cccb88c393d21db51ab7a (patch)
tree625857bea77befb61847c01bf17aac1177255787 /routers/web/repo/editor.go
parent754fdd8f9c2b1e4e78d507fd414968334cf586fd (diff)
downloadgitea-c97d66d23cf14e88514cccb88c393d21db51ab7a.tar.gz
gitea-c97d66d23cf14e88514cccb88c393d21db51ab7a.zip
Move repofiles from modules/repofiles to services/repository/files (#17774)
* Move repofiles from modules to services * rename services/repository/repofiles -> services/repository/files * Fix test Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers/web/repo/editor.go')
-rw-r--r--routers/web/repo/editor.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go
index 088edbfd29..d4fc55979c 100644
--- a/routers/web/repo/editor.go
+++ b/routers/web/repo/editor.go
@@ -19,8 +19,6 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/repofiles"
- repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/typesniffer"
"code.gitea.io/gitea/modules/upload"
@@ -28,6 +26,8 @@ import (
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/utils"
"code.gitea.io/gitea/services/forms"
+ repo_service "code.gitea.io/gitea/services/repository"
+ files_service "code.gitea.io/gitea/services/repository/files"
)
const (
@@ -244,7 +244,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
message += "\n\n" + form.CommitMessage
}
- if _, err := repofiles.CreateOrUpdateRepoFile(ctx.Repo.Repository, ctx.User, &repofiles.UpdateRepoFileOptions{
+ if _, err := files_service.CreateOrUpdateRepoFile(ctx.Repo.Repository, ctx.User, &files_service.UpdateRepoFileOptions{
LastCommitID: form.LastCommit,
OldBranch: ctx.Repo.BranchName,
NewBranch: branchName,
@@ -255,7 +255,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
IsNewFile: isNewFile,
Signoff: form.Signoff,
}); err != nil {
- // This is where we handle all the errors thrown by repofiles.CreateOrUpdateRepoFile
+ // This is where we handle all the errors thrown by files_service.CreateOrUpdateRepoFile
if git.IsErrNotExist(err) {
ctx.RenderWithErr(ctx.Tr("repo.editor.file_editing_no_longer_exists", ctx.Repo.TreePath), tplEditFile, &form)
} else if models.IsErrLFSFileLocked(err) {
@@ -369,7 +369,7 @@ func DiffPreviewPost(ctx *context.Context) {
return
}
- diff, err := repofiles.GetDiffPreview(ctx.Repo.Repository, ctx.Repo.BranchName, treePath, form.Content)
+ diff, err := files_service.GetDiffPreview(ctx.Repo.Repository, ctx.Repo.BranchName, treePath, form.Content)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetDiffPreview: "+err.Error())
return
@@ -450,7 +450,7 @@ func DeleteFilePost(ctx *context.Context) {
message += "\n\n" + form.CommitMessage
}
- if _, err := repofiles.DeleteRepoFile(ctx.Repo.Repository, ctx.User, &repofiles.DeleteRepoFileOptions{
+ if _, err := files_service.DeleteRepoFile(ctx.Repo.Repository, ctx.User, &files_service.DeleteRepoFileOptions{
LastCommitID: form.LastCommit,
OldBranch: ctx.Repo.BranchName,
NewBranch: branchName,
@@ -614,7 +614,7 @@ func UploadFilePost(ctx *context.Context) {
}
if oldBranchName != branchName {
- if _, err := repo_module.GetBranch(ctx.Repo.Repository, branchName); err == nil {
+ if _, err := repo_service.GetBranch(ctx.Repo.Repository, branchName); err == nil {
ctx.Data["Err_NewBranchName"] = true
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchName), tplUploadFile, &form)
return
@@ -658,7 +658,7 @@ func UploadFilePost(ctx *context.Context) {
message += "\n\n" + form.CommitMessage
}
- if err := repofiles.UploadRepoFiles(ctx.Repo.Repository, ctx.User, &repofiles.UploadRepoFileOptions{
+ if err := files_service.UploadRepoFiles(ctx.Repo.Repository, ctx.User, &files_service.UploadRepoFileOptions{
LastCommitID: ctx.Repo.CommitID,
OldBranch: oldBranchName,
NewBranch: branchName,
@@ -806,7 +806,7 @@ func GetUniquePatchBranchName(ctx *context.Context) string {
prefix := ctx.User.LowerName + "-patch-"
for i := 1; i <= 1000; i++ {
branchName := fmt.Sprintf("%s%d", prefix, i)
- if _, err := repo_module.GetBranch(ctx.Repo.Repository, branchName); err != nil {
+ if _, err := repo_service.GetBranch(ctx.Repo.Repository, branchName); err != nil {
if git.IsErrBranchNotExist(err) {
return branchName
}