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

chore: Tweak APPROVALNOTIFIER markdown template to render consistent HTML #1639

Merged

Conversation

azuwis
Copy link
Contributor

@azuwis azuwis commented Jan 7, 2025

Currently the rendered HTML on gitlab is confusing:

This pull-request has been approved by: To complete the pull request process, please assign <user> You can assign the PR to them by writing /lh-assign @<user> in a comment when ready.

The above content are in one paragraph without new lines or ..

Tweak according to CommonMark Spec, since both GitHub Flavored Markdown Spec and GitLab Flavored Markdown are based on it.

Gitlab before:
Screenshot 2025-01-08 at 14 27 29

Gitlab after:
Screenshot 2025-01-08 at 14 27 54

@jenkins-x-bot
Copy link
Contributor

Hi @azuwis. Thanks for your PR.

I'm waiting for a jenkins-x member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository.

@msvticket
Copy link
Member

/ok-to-test

Copy link
Member

@msvticket msvticket left a comment

Choose a reason for hiding this comment

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

Tests need to be updated accordingly. Run make test

@azuwis azuwis force-pushed the tweak-approvalnotifier-template branch from 9fb1591 to 8b4b164 Compare January 8, 2025 06:25
@azuwis
Copy link
Contributor Author

azuwis commented Jan 10, 2025

@msvticket Tests are fixed. Also modified the markdown so that the generate HTML on Github will be exact the same before this change.

Copy link
Member

@msvticket msvticket left a comment

Choose a reason for hiding this comment

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

To me it doesn't look like the change is matching the images in the description of this PR

@azuwis
Copy link
Contributor Author

azuwis commented Jan 10, 2025

The problem

Github does not handle the soft line breaks correctly defined by it's own GitHub Flavored Markdown Spec https://github.github.com/gfm/#soft-line-breaks, it treats soft line breaks and hard line breaks as the same thing.

Gitlab does the right thing, https://about.gitlab.com/blog/2014/02/21/markdown-newline-behaviour/, https://gitlab.com/gitlab-org/gitlab-foss/-/issues/57809, and is different from Github.

The fix

Use hard line breaks, so both Github and Gitlab are happy.

Details

Generate the markdown

Before

Use https://go.dev/play/p/35RYE-Nkkh8 to generate, copied from

want := `[APPROVALNOTIFIER] This PR is **NOT APPROVED**
This pull-request has been approved by: *[Bill](REFERENCE "Approved")*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **alice**
You can assign the PR to them by writing ` + "`/assign @alice`" + ` in a comment when ready.
*No associated issue*. Update pull-request body to add a reference to an issue, or get approval with ` + "`/approve no-issue`" + `
The full list of commands accepted by this bot can be found [here](https://jenkins-x.io/v3/develop/reference/chatops/?repo=org%2Frepo).
<details open>
Needs approval from an approver in each of these files:
- **[a/OWNERS](https://github.com/org/repo/blob/dev/a/OWNERS)**
- ~~[b/OWNERS](https://github.com/org/repo/blob/dev/b/OWNERS)~~ [Bill]
Approvers can indicate their approval by writing ` + "`/approve`" + ` in a comment
Approvers can cancel approval by writing ` + "`/approve cancel`" + ` in a comment
</details>
<!-- META={"approvers":["alice"]} -->`
:

[APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *[Bill](REFERENCE "Approved")*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **alice**
You can assign the PR to them by writing `/assign @alice` in a comment when ready.

*No associated issue*. Update pull-request body to add a reference to an issue, or get approval with `/approve no-issue`

The full list of commands accepted by this bot can be found [here](https://jenkins-x.io/v3/develop/reference/chatops/?repo=org%2Frepo).

<details open>
Needs approval from an approver in each of these files:

- **[a/OWNERS](https://github.com/org/repo/blob/dev/a/OWNERS)**
- ~~[b/OWNERS](https://github.com/org/repo/blob/dev/b/OWNERS)~~ [Bill]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["alice"]} -->

After

Use https://go.dev/play/p/YlXcBuaHj0H to generate, copied from

want := `[APPROVALNOTIFIER] This PR is **NOT APPROVED**
This pull-request has been approved by: *[Bill](REFERENCE "Approved")*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **alice**
You can assign the PR to them by writing ` + "`/assign @alice`" + ` in a comment when ready.
*No associated issue*. Update pull-request body to add a reference to an issue, or get approval with ` + "`/approve no-issue`" + `
The full list of commands accepted by this bot can be found [here](https://jenkins-x.io/v3/develop/reference/chatops/?repo=org%2Frepo).
<details open>
Needs approval from an approver in each of these files:
- **[a/OWNERS](https://github.com/org/repo/blob/dev/a/OWNERS)**
- ~~[b/OWNERS](https://github.com/org/repo/blob/dev/b/OWNERS)~~ [Bill]
Approvers can indicate their approval by writing ` + "`/approve`" + ` in a comment
Approvers can cancel approval by writing ` + "`/approve cancel`" + ` in a comment
</details>
<!-- META={"approvers":["alice"]} -->`
:

[APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *[Bill](REFERENCE "Approved")*  
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **alice**  
You can assign the PR to them by writing `/assign @alice` in a comment when ready.

*No associated issue*. Update pull-request body to add a reference to an issue, or get approval with `/approve no-issue`

The full list of commands accepted by this bot can be found [here](https://jenkins-x.io/v3/develop/reference/chatops/?repo=org%2Frepo).

<details open>
Needs approval from an approver in each of these files:

- **[a/OWNERS](https://github.com/org/repo/blob/dev/a/OWNERS)**
- ~~[b/OWNERS](https://github.com/org/repo/blob/dev/b/OWNERS)~~ [Bill]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["alice"]} -->

Rendered on Github

Before

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Bill
To complete the pull request process, please assign alice
You can assign the PR to them by writing /assign @alice in a comment when ready.

No associated issue. Update pull-request body to add a reference to an issue, or get approval with /approve no-issue

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

After

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Bill
To complete the pull request process, please assign alice
You can assign the PR to them by writing /assign @alice in a comment when ready.

No associated issue. Update pull-request body to add a reference to an issue, or get approval with /approve no-issue

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Render on Gitlab

Copy the markdown, and preview on any Gitlab issue.

Before

Screenshot 2025-01-10 at 18 22 00

After

Screenshot 2025-01-10 at 18 24 28

Conclusion

The rendered HTML on Github is exact the same before and after this change.

The rendered HTML on Gitlab is confusing before this change, and give similar result as Github after.

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

12 similar comments
@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@azuwis
Copy link
Contributor Author

azuwis commented Jan 10, 2025

Need to rebase to current main branch?

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

9 similar comments
@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@msvticket
Copy link
Member

Need to rebase to current main branch?

yes

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

12 similar comments
@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

@jenkins-x-bot
Copy link
Contributor

Failed to merge this PR due to:

failed merging [1639]: [Method Not Allowed]

…HTML

Currently the rendered HTML on gitlab is confusing:

```
This pull-request has been approved by: To complete the pull request process, please assign <user> You can assign the PR to them by writing /lh-assign @<user> in a comment when ready.
```

The above content are in one paragraph without new lines or `.`.

Tweak according to [CommonMark Spec][1], since both [GitHub Flavored Markdown
Spec][2] and [GitLab Flavored Markdown][3] are based on it.

[1]: https://spec.commonmark.org/0.31.2/#hard-line-breaks
[2]: https://github.github.com/gfm/#hard-line-breaks
[3]: https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/user/markdown.md#newlines
@msvticket msvticket force-pushed the tweak-approvalnotifier-template branch from 8b4b164 to 83e4aa6 Compare January 10, 2025 11:57
@jenkins-x-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: msvticket

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@msvticket
Copy link
Member

/retest

@jenkins-x-bot jenkins-x-bot merged commit 8859f66 into jenkins-x:main Jan 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants