diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-02-14 13:21:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-14 05:21:31 +0000 |
commit | b426e383fe1a75680a0ebc349e7c939aa438e8db (patch) | |
tree | c65ed039e6d785f9f14376c00d84df47402fd744 | |
parent | d88b01252519ef3215243df4d1c0c365e41628c9 (diff) | |
download | gitea-b426e383fe1a75680a0ebc349e7c939aa438e8db.tar.gz gitea-b426e383fe1a75680a0ebc349e7c939aa438e8db.zip |
Fix PR's target branch dropdown (#33589)
Fix #33586
It only moves `PrepareBranchList` and `retrieveAssigneesData` to before
the `CanModifyIssueOrPull` check, and adds more comments
-rw-r--r-- | routers/web/repo/issue_page_meta.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/routers/web/repo/issue_page_meta.go b/routers/web/repo/issue_page_meta.go index 272343f460..93cc38bffa 100644 --- a/routers/web/repo/issue_page_meta.go +++ b/routers/web/repo/issue_page_meta.go @@ -79,27 +79,35 @@ func retrieveRepoIssueMetaData(ctx *context.Context, repo *repo_model.Repository return data } - data.CanModifyIssueOrPull = ctx.Repo.CanWriteIssuesOrPulls(isPull) && !ctx.Repo.Repository.IsArchived - if !data.CanModifyIssueOrPull { + // it sets "Branches" template data, + // it is used to render the "edit PR target branches" dropdown, and the "branch selector" in the issue's sidebar. + PrepareBranchList(ctx) + if ctx.Written() { return data } - data.retrieveAssigneesDataForIssueWriter(ctx) + // it sets the "Assignees" template data, and the data is also used to "mention" users. + data.retrieveAssigneesData(ctx) if ctx.Written() { return data } - data.retrieveMilestonesDataForIssueWriter(ctx) - if ctx.Written() { + // TODO: the issue/pull permissions are quite complex and unclear + // A reader could create an issue/PR with setting some meta (eg: assignees from issue template, reviewers, target branch) + // A reader(creator) could update some meta (eg: target branch), but can't change assignees anymore. + // For non-creator users, only writers could update some meta (eg: assignees, milestone, project) + // Need to clarify the logic and add some tests in the future + data.CanModifyIssueOrPull = ctx.Repo.CanWriteIssuesOrPulls(isPull) && !ctx.Repo.Repository.IsArchived + if !data.CanModifyIssueOrPull { return data } - data.retrieveProjectsDataForIssueWriter(ctx) + data.retrieveMilestonesDataForIssueWriter(ctx) if ctx.Written() { return data } - PrepareBranchList(ctx) + data.retrieveProjectsDataForIssueWriter(ctx) if ctx.Written() { return data } @@ -131,7 +139,7 @@ func (d *IssuePageMetaData) retrieveMilestonesDataForIssueWriter(ctx *context.Co } } -func (d *IssuePageMetaData) retrieveAssigneesDataForIssueWriter(ctx *context.Context) { +func (d *IssuePageMetaData) retrieveAssigneesData(ctx *context.Context) { var err error d.AssigneesData.CandidateAssignees, err = repo_model.GetRepoAssignees(ctx, d.Repository) if err != nil { |