Skip to content

Escape GitHub @mentions in template update PR bodies#491

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/escape-github-usernames-release
Draft

Escape GitHub @mentions in template update PR bodies#491
Copilot wants to merge 2 commits intomainfrom
copilot/escape-github-usernames-release

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

Release notes included in cruft update PRs contain raw @username mentions, causing all contributors to be subscribed to 150+ PRs on every release.

  • Add _escape_github_mentions() to wrap @username`@username` using regex with negative lookbehind to skip already-escaped mentions and email addresses
  • Apply escaping in TemplateUpdatePR.body after template formatting
  • Add parametrized tests covering mentions, emails, backtick-escaped handles, and realistic release notes
>>> _escape_github_mentions("* Fix bug by @grst in https://...")
'* Fix bug by `@grst` in https://...'

>>> _escape_github_mentions("`@already-escaped`")  # unchanged
'`@already-escaped`'

>>> _escape_github_mentions("bot@users.noreply.github.com")  # unchanged
'bot@users.noreply.github.com'

Copilot AI linked an issue Mar 30, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Automate escaping GitHub usernames in release messages Escape GitHub @mentions in template update PR bodies Mar 30, 2026
Copilot AI requested a review from grst March 30, 2026 20:31
Copilot finished work on behalf of grst March 30, 2026 20:31
Copy link
Copy Markdown
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

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

it’s probably fine, but if we wanted this to be robust, we’d need to

  1. parse markdown
  2. find the spans containing usernames
    • if we parsed it as GFM with the username extension – just use that
    • if we parsed as regular markdown – find the @… pattern in regular text parts (but not code parts or so)
  3. replace (I guess just reversing the list of replacements before performing them would be fine)

@grst
Copy link
Copy Markdown
Collaborator

grst commented Mar 31, 2026

I like the suggestion. Is there any library for GFM parsing that you would recommend?

@flying-sheep
Copy link
Copy Markdown
Member

Hm, the established ones don’t have a real AST with source locations, but this one looks good: https://lbliii.github.io/patitas/

@grst
Copy link
Copy Markdown
Collaborator

grst commented Mar 31, 2026

are you sure this supports parsing usernames? I couldn't find anything related to that in the docs...

@github-actions
Copy link
Copy Markdown

A PR has been generated to the instance repo: scverse/cookiecutter-scverse-instance#269

Checks Status Documentation Preview

You can check out the PR to preview your changes in an instance of the cookiecutter template.
It will be kept in sync with this PR automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

escape github usernames on release

3 participants