Fix Agit pull request permission check (#32999) (#33005)

Backport #32999 by @a1012112796

user with read permission should also can create agit flow pull request.
looks this logic was broken in
https://github.com/go-gitea/gitea/pull/31033 this pull request try fix
it and add test code.

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot 2024-12-28 11:34:28 +08:00 committed by GitHub
parent 0137bc4e5c
commit f35ab5cd52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -65,7 +65,8 @@ func NewPullRequest(ctx context.Context, opts *NewPullRequestOptions) error {
}
// user should be a collaborator or a member of the organization for base repo
if !issue.Poster.IsAdmin {
canCreate := issue.Poster.IsAdmin || pr.Flow == issues_model.PullRequestFlowAGit
if !canCreate {
canCreate, err := repo_model.IsOwnerMemberCollaborator(ctx, repo, issue.Poster.ID)
if err != nil {
return err