Skip to content

Commit 80e5640

Browse files
GiteaBotdenyskondelvh
authored
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 <[email protected]> Co-authored-by: delvh <[email protected]>
1 parent 571822b commit 80e5640

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

routers/web/repo/compare.go

+1
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ func CompareDiff(ctx *context.Context) {
844844
}
845845
}
846846

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

routers/web/repo/pull.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13711371
return
13721372
}
13731373

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

1452+
if projectID > 0 {
1453+
if !ctx.Repo.CanWrite(unit.TypeProjects) {
1454+
ctx.Error(http.StatusBadRequest, "user hasn't the permission to write to projects")
1455+
return
1456+
}
1457+
if err := issues_model.ChangeProjectAssign(pullIssue, ctx.Doer, projectID); err != nil {
1458+
ctx.ServerError("ChangeProjectAssign", err)
1459+
return
1460+
}
1461+
}
1462+
14521463
log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID)
14531464
ctx.JSONRedirect(pullIssue.Link())
14541465
}

0 commit comments

Comments
 (0)