summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/branch.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-20 22:08:52 +0800
committerGitHub <noreply@github.com>2022-05-20 22:08:52 +0800
commitfd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch)
tree50038348ec10485f72344f3ac80324e04abc1283 /routers/api/v1/repo/branch.go
parentd81e31ad7826a81fc7139f329f250594610a274b (diff)
downloadgitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz
gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
Diffstat (limited to 'routers/api/v1/repo/branch.go')
-rw-r--r--routers/api/v1/repo/branch.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index c030a896a7..09e6ccf238 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -70,7 +70,7 @@ func GetBranch(ctx *context.APIContext) {
return
}
- branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branchName)
+ branchProtection, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
@@ -206,7 +206,7 @@ func CreateBranch(ctx *context.APIContext) {
return
}
- branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branch.Name)
+ branchProtection, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branch.Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
@@ -271,7 +271,7 @@ func ListBranches(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
return
}
- branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branches[i].Name)
+ branchProtection, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branches[i].Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
@@ -320,7 +320,7 @@ func GetBranchProtection(ctx *context.APIContext) {
repo := ctx.Repo.Repository
bpName := ctx.Params(":name")
- bp, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ bp, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return
@@ -412,7 +412,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
return
}
- protectBranch, err := models.GetProtectedBranchBy(repo.ID, form.BranchName)
+ protectBranch, err := models.GetProtectedBranchBy(ctx, repo.ID, form.BranchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectBranchOfRepoByName", err)
return
@@ -523,7 +523,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
}
// Reload from db to get all whitelists
- bp, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, form.BranchName)
+ bp, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, form.BranchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return
@@ -575,7 +575,7 @@ func EditBranchProtection(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.EditBranchProtectionOption)
repo := ctx.Repo.Repository
bpName := ctx.Params(":name")
- protectBranch, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ protectBranch, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return
@@ -758,7 +758,7 @@ func EditBranchProtection(ctx *context.APIContext) {
}
// Reload from db to ensure get all whitelists
- bp, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ bp, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchBy", err)
return
@@ -802,7 +802,7 @@ func DeleteBranchProtection(ctx *context.APIContext) {
repo := ctx.Repo.Repository
bpName := ctx.Params(":name")
- bp, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ bp, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return