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 templating in pull request comparison #33025

Merged
merged 8 commits into from
Dec 29, 2024

Conversation

TheFox0x7
Copy link
Contributor

Adds test for expected behavior

Closes: #33013


I'm not stuck on details being empty - I just don't know what to put in there. Suggestions welcome :)

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 28, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 28, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Dec 28, 2024
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 28, 2024

I think it's better to fix it in template, but not add empty values to the map. Because if there is no details, the template shouldn't render that part.

(And in case the future developers would forget/not know that there must be a detail to make the template work ....)

{{.Message}}
<details>
	<summary>{{.Summary}}</summary>
	{{if .Details}}<code>{{.Details | SanitizeHTML}}</code>{{end}}
</details>

@TheFox0x7
Copy link
Contributor Author

This works but there's a downside of there still being the drop down arrow for it without any contents:
image

I came up with this to fix it:

{{.Message}}
{{ if .Details }}
<details>
	<summary>{{.Summary}}</summary>
	<code>{{.Details | SanitizeHTML}}</code>
</details>
{{ else }}
<div>
	{{ .Summary }}
</div>
{{ end }}

image

Let me know if that works or if I should leave the version with empty contents. I'm not sure if that has any impact somewhere else.

@wxiaoguang
Copy link
Contributor

I came up with this to fix it:

Yup, that's even better. Thank you!

@github-actions github-actions bot added the modifies/templates This PR modifies the template files label Dec 28, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 28, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 28, 2024
@lunny lunny added this to the 1.24.0 milestone Dec 28, 2024
@wxiaoguang wxiaoguang enabled auto-merge (squash) December 28, 2024 18:52
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Dec 29, 2024
@lunny
Copy link
Member

lunny commented Dec 29, 2024

I think this could be backport to v1.23

@wxiaoguang wxiaoguang merged commit ff96873 into go-gitea:main Dec 29, 2024
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Dec 29, 2024
@wxiaoguang wxiaoguang added the backport/v1.23 This PR should be backported to Gitea 1.23 label Dec 29, 2024
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Dec 29, 2024
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.23 This PR should be backported to Gitea 1.23 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alert templates on pull request comparison page don't work
4 participants