Skip to content

Commit 09507db

Browse files
denyskonsilverwind
authored andcommitted
Assign pull request to project during creation (go-gitea#28227)
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)
1 parent 2e4a0c1 commit 09507db

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
@@ -845,6 +845,7 @@ func CompareDiff(ctx *context.Context) {
845845
}
846846
}
847847

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

routers/web/repo/pull.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13871387
return
13881388
}
13891389

1390-
labelIDs, assigneeIDs, milestoneID, _ := ValidateRepoMetas(ctx, *form, true)
1390+
labelIDs, assigneeIDs, milestoneID, projectID := ValidateRepoMetas(ctx, *form, true)
13911391
if ctx.Written() {
13921392
return
13931393
}
@@ -1465,6 +1465,17 @@ func CompareAndPullRequestPost(ctx *context.Context) {
14651465
return
14661466
}
14671467

1468+
if projectID > 0 {
1469+
if !ctx.Repo.CanWrite(unit.TypeProjects) {
1470+
ctx.Error(http.StatusBadRequest, "user hasn't the permission to write to projects")
1471+
return
1472+
}
1473+
if err := issues_model.ChangeProjectAssign(ctx, pullIssue, ctx.Doer, projectID); err != nil {
1474+
ctx.ServerError("ChangeProjectAssign", err)
1475+
return
1476+
}
1477+
}
1478+
14681479
log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID)
14691480
ctx.JSONRedirect(pullIssue.Link())
14701481
}

0 commit comments

Comments
 (0)