diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-05-11 18:09:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-11 12:09:36 +0200 |
commit | cbd45471b1100bffcd2f18719b56a5da5468756b (patch) | |
tree | 11fcb818fd4e9d7b6bdb97d1b5bfbe2ed3df5747 /routers/private/hook_pre_receive.go | |
parent | 8e8e936adacea873013b89d534f60207e67f2b05 (diff) | |
download | gitea-cbd45471b1100bffcd2f18719b56a5da5468756b.tar.gz gitea-cbd45471b1100bffcd2f18719b56a5da5468756b.zip |
Move access and repo permission to models/perm/access (#19350)
* Move access and repo permission to models/perm/access
* Remove unnecessary code
Diffstat (limited to 'routers/private/hook_pre_receive.go')
-rw-r--r-- | routers/private/hook_pre_receive.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go index d2203a1f99..9d3d665264 100644 --- a/routers/private/hook_pre_receive.go +++ b/routers/private/hook_pre_receive.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/models" asymkey_model "code.gitea.io/gitea/models/asymkey" perm_model "code.gitea.io/gitea/models/perm" + access_model "code.gitea.io/gitea/models/perm/access" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" gitea_context "code.gitea.io/gitea/modules/context" @@ -30,7 +31,7 @@ type preReceiveContext struct { // loadedPusher indicates that where the following information are loaded loadedPusher bool user *user_model.User // it's the org user if a DeployKey is used - userPerm models.Permission + userPerm access_model.Permission deployKeyAccessMode perm_model.AccessMode canCreatePullRequest bool @@ -55,7 +56,7 @@ func (ctx *preReceiveContext) CanWriteCode() bool { if !ctx.loadPusherAndPermission() { return false } - ctx.canWriteCode = ctx.userPerm.CanWriteToBranch(ctx.user, ctx.branchName) || ctx.deployKeyAccessMode >= perm_model.AccessModeWrite + ctx.canWriteCode = models.CanMaintainerWriteToBranch(ctx.userPerm, ctx.branchName, ctx.user) || ctx.deployKeyAccessMode >= perm_model.AccessModeWrite ctx.checkedCanWriteCode = true } return ctx.canWriteCode @@ -472,7 +473,7 @@ func (ctx *preReceiveContext) loadPusherAndPermission() bool { } ctx.user = user - userPerm, err := models.GetUserRepoPermission(ctx, ctx.Repo.Repository, user) + userPerm, err := access_model.GetUserRepoPermission(ctx, ctx.Repo.Repository, user) if err != nil { log.Error("Unable to get Repo permission of repo %s/%s of User %s", ctx.Repo.Repository.OwnerName, ctx.Repo.Repository.Name, user.Name, err) ctx.JSON(http.StatusInternalServerError, private.Response{ |