1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Move some repository related code into sub package (#19711)

* Move some repository related code into sub package

* Move more repository functions out of models

* Fix lint

* Some performance optimization for webhooks and others

* some refactors

* Fix lint

* Fix

* Update modules/repository/delete.go

Co-authored-by: delvh <dev.lh@web.de>

* Fix test

* Merge

* Fix test

* Fix test

* Fix test

* Fix test

Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
Lunny Xiao
2022-06-06 16:01:49 +08:00
committed by GitHub
parent ebeb6e7c71
commit 26095115f4
76 changed files with 1756 additions and 1674 deletions

View File

@@ -152,7 +152,7 @@ func Create(ctx *context.Context) {
templateID := ctx.FormInt64("template_id")
if templateID > 0 {
templateRepo, err := repo_model.GetRepositoryByID(templateID)
if err == nil && models.CheckRepoUnitUser(templateRepo, ctxUser, unit.TypeCode) {
if err == nil && models.CheckRepoUnitUser(ctx, templateRepo, ctxUser, unit.TypeCode) {
ctx.Data["repo_template"] = templateID
ctx.Data["repo_template_name"] = templateRepo.Name
}
@@ -223,7 +223,7 @@ func CreatePost(ctx *context.Context) {
var repo *repo_model.Repository
var err error
if form.RepoTemplate > 0 {
opts := models.GenerateRepoOptions{
opts := repo_module.GenerateRepoOptions{
Name: form.RepoName,
Description: form.Description,
Private: form.Private,
@@ -304,7 +304,7 @@ func Action(ctx *context.Context) {
ctx.Repo.Repository.Description = ctx.FormString("desc")
ctx.Repo.Repository.Website = ctx.FormString("site")
err = models.UpdateRepository(ctx.Repo.Repository, false)
err = repo_service.UpdateRepository(ctx.Repo.Repository, false)
}
if err != nil {
@@ -509,7 +509,7 @@ func InitiateDownload(ctx *context.Context) {
// SearchRepo repositories via options
func SearchRepo(ctx *context.Context) {
opts := &models.SearchRepoOptions{
opts := &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
Page: ctx.FormInt("page"),
PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
@@ -581,7 +581,7 @@ func SearchRepo(ctx *context.Context) {
}
var err error
repos, count, err := models.SearchRepository(opts)
repos, count, err := repo_model.SearchRepository(opts)
if err != nil {
ctx.JSON(http.StatusInternalServerError, api.SearchError{
OK: false,