aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/setting_protected_branch.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 09:27:50 +0800
committerGitHub <noreply@github.com>2021-12-10 09:27:50 +0800
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /routers/web/repo/setting_protected_branch.go
parentfb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff)
downloadgitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz
gitea-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'routers/web/repo/setting_protected_branch.go')
-rw-r--r--routers/web/repo/setting_protected_branch.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/routers/web/repo/setting_protected_branch.go b/routers/web/repo/setting_protected_branch.go
index e0580ac6de..1435b820ad 100644
--- a/routers/web/repo/setting_protected_branch.go
+++ b/routers/web/repo/setting_protected_branch.go
@@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/perm"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
@@ -29,7 +30,7 @@ func ProtectedBranch(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsBranches"] = true
- protectedBranches, err := ctx.Repo.Repository.GetProtectedBranches()
+ protectedBranches, err := models.GetProtectedBranches(ctx.Repo.Repository.ID)
if err != nil {
ctx.ServerError("GetProtectedBranches", err)
return
@@ -82,7 +83,7 @@ func ProtectedBranchPost(ctx *context.Context) {
return
}
}
- if err := repo.UpdateDefaultBranch(); err != nil {
+ if err := repo_model.UpdateDefaultBranch(repo); err != nil {
ctx.ServerError("SetDefaultBranch", err)
return
}
@@ -123,7 +124,7 @@ func SettingsProtectedBranch(c *context.Context) {
}
}
- users, err := c.Repo.Repository.GetReaders()
+ users, err := models.GetRepoReaders(c.Repo.Repository)
if err != nil {
c.ServerError("Repo.Repository.GetReaders", err)
return
@@ -279,7 +280,7 @@ func SettingsProtectedBranchPost(ctx *context.Context) {
ctx.Redirect(fmt.Sprintf("%s/settings/branches/%s", ctx.Repo.RepoLink, util.PathEscapeSegments(branch)))
} else {
if protectBranch != nil {
- if err := ctx.Repo.Repository.DeleteProtectedBranch(protectBranch.ID); err != nil {
+ if err := models.DeleteProtectedBranch(ctx.Repo.Repository.ID, protectBranch.ID); err != nil {
ctx.ServerError("DeleteProtectedBranch", err)
return
}