瀏覽代碼

Assign pull request to project during creation (#28227) (#28775)

Backport #28227 by @denyskon

When creating a pull request, allow directly assigning it to a project,
as it is already possible for issues.

After:


![grafik](https://github.com/go-gitea/gitea/assets/47871822/01dc2b3d-d56a-4053-b2fc-138725d7633a)

---------

Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Co-authored-by: delvh <dev.lh@web.de>
tags/v1.21.4
Giteabot 4 月之前
父節點
當前提交
80e564087d
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 13 行新增1 行删除
  1. 1
    0
      routers/web/repo/compare.go
  2. 12
    1
      routers/web/repo/pull.go

+ 1
- 0
routers/web/repo/compare.go 查看文件

@@ -844,6 +844,7 @@ func CompareDiff(ctx *context.Context) {
}
}

ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanWrite(unit.TypeProjects)
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
upload.AddUploadContext(ctx, "comment")


+ 12
- 1
routers/web/repo/pull.go 查看文件

@@ -1371,7 +1371,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
return
}

labelIDs, assigneeIDs, milestoneID, _ := ValidateRepoMetas(ctx, *form, true)
labelIDs, assigneeIDs, milestoneID, projectID := ValidateRepoMetas(ctx, *form, true)
if ctx.Written() {
return
}
@@ -1449,6 +1449,17 @@ func CompareAndPullRequestPost(ctx *context.Context) {
return
}

if projectID > 0 {
if !ctx.Repo.CanWrite(unit.TypeProjects) {
ctx.Error(http.StatusBadRequest, "user hasn't the permission to write to projects")
return
}
if err := issues_model.ChangeProjectAssign(pullIssue, ctx.Doer, projectID); err != nil {
ctx.ServerError("ChangeProjectAssign", err)
return
}
}

log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID)
ctx.JSONRedirect(pullIssue.Link())
}

Loading…
取消
儲存