summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/repo/blob.go4
-rw-r--r--routers/api/v1/repo/branch.go5
-rw-r--r--routers/api/v1/repo/file.go34
-rw-r--r--routers/api/v1/repo/status.go4
-rw-r--r--routers/api/v1/repo/tree.go4
5 files changed, 25 insertions, 26 deletions
diff --git a/routers/api/v1/repo/blob.go b/routers/api/v1/repo/blob.go
index 3918a49d51..e3ce0e1916 100644
--- a/routers/api/v1/repo/blob.go
+++ b/routers/api/v1/repo/blob.go
@@ -8,7 +8,7 @@ import (
"net/http"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/repofiles"
+ files_service "code.gitea.io/gitea/services/repository/files"
)
// GetBlob get the blob of a repository file.
@@ -45,7 +45,7 @@ func GetBlob(ctx *context.APIContext) {
ctx.Error(http.StatusBadRequest, "", "sha not provided")
return
}
- if blob, err := repofiles.GetBlobBySHA(ctx.Repo.Repository, sha); err != nil {
+ if blob, err := files_service.GetBlobBySHA(ctx.Repo.Repository, sha); err != nil {
ctx.Error(http.StatusBadRequest, "", err)
} else {
ctx.JSON(http.StatusOK, blob)
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index 2e08b56826..04da901239 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -14,7 +14,6 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
- repo_module "code.gitea.io/gitea/modules/repository"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/api/v1/utils"
@@ -53,7 +52,7 @@ func GetBranch(ctx *context.APIContext) {
branchName := ctx.Params("*")
- branch, err := repo_module.GetBranch(ctx.Repo.Repository, branchName)
+ branch, err := repo_service.GetBranch(ctx.Repo.Repository, branchName)
if err != nil {
if git.IsErrBranchNotExist(err) {
ctx.NotFound(err)
@@ -198,7 +197,7 @@ func CreateBranch(ctx *context.APIContext) {
return
}
- branch, err := repo_module.GetBranch(ctx.Repo.Repository, opt.BranchName)
+ branch, err := repo_service.GetBranch(ctx.Repo.Repository, opt.BranchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranch", err)
return
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 009b8a26d6..e84f652ed9 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -15,11 +15,11 @@ import (
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
- "code.gitea.io/gitea/modules/repofiles"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/common"
"code.gitea.io/gitea/routers/web/repo"
+ files_service "code.gitea.io/gitea/services/repository/files"
)
// GetRawFile get a file by path on a repository
@@ -240,22 +240,22 @@ func CreateFile(ctx *context.APIContext) {
apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch
}
- opts := &repofiles.UpdateRepoFileOptions{
+ opts := &files_service.UpdateRepoFileOptions{
Content: apiOpts.Content,
IsNewFile: true,
Message: apiOpts.Message,
TreePath: ctx.Params("*"),
OldBranch: apiOpts.BranchName,
NewBranch: apiOpts.NewBranchName,
- Committer: &repofiles.IdentityOptions{
+ Committer: &files_service.IdentityOptions{
Name: apiOpts.Committer.Name,
Email: apiOpts.Committer.Email,
},
- Author: &repofiles.IdentityOptions{
+ Author: &files_service.IdentityOptions{
Name: apiOpts.Author.Name,
Email: apiOpts.Author.Email,
},
- Dates: &repofiles.CommitDateOptions{
+ Dates: &files_service.CommitDateOptions{
Author: apiOpts.Dates.Author,
Committer: apiOpts.Dates.Committer,
},
@@ -327,7 +327,7 @@ func UpdateFile(ctx *context.APIContext) {
apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch
}
- opts := &repofiles.UpdateRepoFileOptions{
+ opts := &files_service.UpdateRepoFileOptions{
Content: apiOpts.Content,
SHA: apiOpts.SHA,
IsNewFile: false,
@@ -336,15 +336,15 @@ func UpdateFile(ctx *context.APIContext) {
TreePath: ctx.Params("*"),
OldBranch: apiOpts.BranchName,
NewBranch: apiOpts.NewBranchName,
- Committer: &repofiles.IdentityOptions{
+ Committer: &files_service.IdentityOptions{
Name: apiOpts.Committer.Name,
Email: apiOpts.Committer.Email,
},
- Author: &repofiles.IdentityOptions{
+ Author: &files_service.IdentityOptions{
Name: apiOpts.Author.Name,
Email: apiOpts.Author.Email,
},
- Dates: &repofiles.CommitDateOptions{
+ Dates: &files_service.CommitDateOptions{
Author: apiOpts.Dates.Author,
Committer: apiOpts.Dates.Committer,
},
@@ -387,7 +387,7 @@ func handleCreateOrUpdateFileError(ctx *context.APIContext, err error) {
}
// Called from both CreateFile or UpdateFile to handle both
-func createOrUpdateFile(ctx *context.APIContext, opts *repofiles.UpdateRepoFileOptions) (*api.FileResponse, error) {
+func createOrUpdateFile(ctx *context.APIContext, opts *files_service.UpdateRepoFileOptions) (*api.FileResponse, error) {
if !canWriteFiles(ctx.Repo) {
return nil, models.ErrUserDoesNotHaveAccessToRepo{
UserID: ctx.User.ID,
@@ -401,7 +401,7 @@ func createOrUpdateFile(ctx *context.APIContext, opts *repofiles.UpdateRepoFileO
}
opts.Content = string(content)
- return repofiles.CreateOrUpdateRepoFile(ctx.Repo.Repository, ctx.User, opts)
+ return files_service.CreateOrUpdateRepoFile(ctx.Repo.Repository, ctx.User, opts)
}
// DeleteFile Delete a fle in a repository
@@ -457,21 +457,21 @@ func DeleteFile(ctx *context.APIContext) {
apiOpts.BranchName = ctx.Repo.Repository.DefaultBranch
}
- opts := &repofiles.DeleteRepoFileOptions{
+ opts := &files_service.DeleteRepoFileOptions{
Message: apiOpts.Message,
OldBranch: apiOpts.BranchName,
NewBranch: apiOpts.NewBranchName,
SHA: apiOpts.SHA,
TreePath: ctx.Params("*"),
- Committer: &repofiles.IdentityOptions{
+ Committer: &files_service.IdentityOptions{
Name: apiOpts.Committer.Name,
Email: apiOpts.Committer.Email,
},
- Author: &repofiles.IdentityOptions{
+ Author: &files_service.IdentityOptions{
Name: apiOpts.Author.Name,
Email: apiOpts.Author.Email,
},
- Dates: &repofiles.CommitDateOptions{
+ Dates: &files_service.CommitDateOptions{
Author: apiOpts.Dates.Author,
Committer: apiOpts.Dates.Committer,
},
@@ -488,7 +488,7 @@ func DeleteFile(ctx *context.APIContext) {
opts.Message = ctx.Tr("repo.editor.delete", opts.TreePath)
}
- if fileResponse, err := repofiles.DeleteRepoFile(ctx.Repo.Repository, ctx.User, opts); err != nil {
+ if fileResponse, err := files_service.DeleteRepoFile(ctx.Repo.Repository, ctx.User, opts); err != nil {
if git.IsErrBranchNotExist(err) || models.IsErrRepoFileDoesNotExist(err) || git.IsErrNotExist(err) {
ctx.Error(http.StatusNotFound, "DeleteFile", err)
return
@@ -554,7 +554,7 @@ func GetContents(ctx *context.APIContext) {
treePath := ctx.Params("*")
ref := ctx.FormTrim("ref")
- if fileList, err := repofiles.GetContentsOrList(ctx.Repo.Repository, treePath, ref); err != nil {
+ if fileList, err := files_service.GetContentsOrList(ctx.Repo.Repository, treePath, ref); err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetContentsOrList", err)
return
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index b884432f73..583b89dd7a 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -11,10 +11,10 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
- "code.gitea.io/gitea/modules/repofiles"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/api/v1/utils"
+ files_service "code.gitea.io/gitea/services/repository/files"
)
// NewCommitStatus creates a new CommitStatus
@@ -62,7 +62,7 @@ func NewCommitStatus(ctx *context.APIContext) {
Description: form.Description,
Context: form.Context,
}
- if err := repofiles.CreateCommitStatus(ctx.Repo.Repository, ctx.User, sha, status); err != nil {
+ if err := files_service.CreateCommitStatus(ctx.Repo.Repository, ctx.User, sha, status); err != nil {
ctx.Error(http.StatusInternalServerError, "CreateCommitStatus", err)
return
}
diff --git a/routers/api/v1/repo/tree.go b/routers/api/v1/repo/tree.go
index aec336235d..2168a311d0 100644
--- a/routers/api/v1/repo/tree.go
+++ b/routers/api/v1/repo/tree.go
@@ -8,7 +8,7 @@ import (
"net/http"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/repofiles"
+ files_service "code.gitea.io/gitea/services/repository/files"
)
// GetTree get the tree of a repository.
@@ -60,7 +60,7 @@ func GetTree(ctx *context.APIContext) {
ctx.Error(http.StatusBadRequest, "", "sha not provided")
return
}
- if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.FormInt("page"), ctx.FormInt("per_page"), ctx.FormBool("recursive")); err != nil {
+ if tree, err := files_service.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.FormInt("page"), ctx.FormInt("per_page"), ctx.FormBool("recursive")); err != nil {
ctx.Error(http.StatusBadRequest, "", err.Error())
} else {
ctx.JSON(http.StatusOK, tree)