8000 Fix PR's target branch dropdown (#33589) by wxiaoguang · Pull Request #33591 · go-gitea/gitea · GitHub
[go: up one dir, main page]

Skip to content

Fix PR's target branch dropdown (#33589) #33591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
Next Next commit
Fix PR's target branch dropdown (#33589)
Fix #33586

It only moves `PrepareBranchList` and `retrieveAssigneesData` to before
the `CanModifyIssueOrPull` check, and adds more comments
  • Loading branch information
wxiaoguang committed Feb 14, 2025
commit a718ba2d78d20ec83b9f58d94e4c2d58499d5f2d
24 changes: 16 additions & 8 deletions routers/web/repo/issue_page_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
Loading
0