Skip to content
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

Fix incorrect redirection when creating a PR fails #29537

Merged
merged 3 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
Diff view
4 changes: 2 additions & 2 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1792,9 +1792,9 @@ pulls.unrelated_histories = Merge Failed: The merge head and base do not share a
pulls.merge_out_of_date = Merge Failed: Whilst generating the merge, the base was updated. Hint: Try again.
pulls.head_out_of_date = Merge Failed: Whilst generating the merge, the head was updated. Hint: Try again.
pulls.has_merged = Failed: The pull request has been merged, you cannot merge again or change the target branch.
pulls.push_rejected = Merge Failed: The push was rejected. Review the Git Hooks for this repository.
pulls.push_rejected = Push Failed: The push was rejected. Review the Git Hooks for this repository.
pulls.push_rejected_summary = Full Rejection Message
pulls.push_rejected_no_message = Merge Failed: The push was rejected but there was no remote message.<br>Review the Git Hooks for this repository
pulls.push_rejected_no_message = Push Failed: The push was rejected but there was no remote message. Review the Git Hooks for this repository
pulls.open_unmerged_pull_exists = `You cannot perform a reopen operation because there is a pending pull request (#%d) with identical properties.`
pulls.status_checking = Some checks are pending
pulls.status_checks_success = All checks were successful
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
return
}
ctx.Flash.Error(flashError)
ctx.JSONRedirect(pullIssue.Link()) // FIXME: it's unfriendly, and will make the content lost
ctx.JSONRedirect(ctx.Link + "?" + ctx.Req.URL.RawQuery) // FIXME: it's unfriendly, and will make the content lost
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still unfriendly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. See the description:

This is only a quick fix to make it easier to backport.
After this PR gets merged, I will propose a new PR to fix the FIXME.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the filled form content will be lost because of the redirection. (The pull request title and content)
But it's the same behavior as before. So this can be resolved in future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> Make PR form use toast to show error message #29545

return
}
ctx.ServerError("NewPullRequest", err)
Expand Down
8 changes: 0 additions & 8 deletions templates/repo/diff/compare.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
{{ctx.Locale.Tr "action.compare_commits_general"}}
{{end}}
</h2>
{{if .Flash.WarningMsg}}
{{/*
There's already an importing of alert.tmpl in new_form.tmpl,
but only the negative message will be displayed within forms for some reasons, see semantic.css:10659.
To avoid repeated negative messages, the importing here if for .Flash.WarningMsg only.
*/}}
{{template "base/alert" .}}
{{end}}
{{$BaseCompareName := $.BaseName -}}
{{- $HeadCompareName := $.HeadRepo.OwnerName -}}
{{- if and (eq $.BaseName $.HeadRepo.OwnerName) (ne $.Repository.Name $.HeadRepo.Name) -}}
Expand Down
8 changes: 0 additions & 8 deletions templates/repo/issue/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
<div role="main" aria-label="{{.Title}}" class="page-content repository new issue">
{{template "repo/header" .}}
<div class="ui container">
{{if .Flash.WarningMsg}}
{{/*
There's already an importing of alert.tmpl in new_form.tmpl,
but only the negative message will be displayed within forms for some reasons, see semantic.css:10659.
To avoid repeated negative messages, the importing here if for .Flash.WarningMsg only.
*/}}
{{template "base/alert" .}}
{{end}}
{{template "repo/issue/new_form" .}}
</div>
</div>
Expand Down
8 changes: 3 additions & 5 deletions templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{{if .Flash}}
{{template "base/alert" .}}
{{end}}
<form class="issue-content ui comment form form-fetch-action" id="new-issue" action="{{.Link}}" method="post">
{{.CsrfTokenHtml}}
{{if .Flash}}
<div class="sixteen wide column">
{{template "base/alert" .}}
</div>
{{end}}
<div class="issue-content-left">
<div class="ui comments">
<div class="comment">
Expand Down
Loading