Skip to content

Commit 4ba1d2f

Browse files
CopilotricardoV94
andcommitted
Convert release notes mentions to links
This sidesteps Discourse API mentions limit Co-authored-by: Ricardo Vieira <28983449+ricardov94@users.noreply.github.com>
1 parent adb79be commit 4ba1d2f

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

scripts/publish_release_notes_to_discourse.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def format_release_content(config: dict[str, str]) -> tuple[str, str]:
7070
config["RELEASE_BODY"],
7171
)
7272

73+
# Convert user mentions to GitHub profile links to avoid Discourse API limit of 10 mentions per post
74+
# Replace @username with [@username](https://github.com/username)
75+
release_body = re.sub(r"@([\w-]+)", r"[@\1](https://github.com/\1)", release_body)
76+
7377
content = f"""A new release of **{repo_name}** is now available!
7478
7579
## 📦 Release Information

scripts/test_publish_release_notes.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_non_pymc_links_unchanged(self):
103103
"RELEASE_URL": "https://github.com/pymc-devs/pymc/releases/tag/v1.0.0",
104104
}
105105

106-
title, content = format_release_content(config)
106+
_title, content = format_release_content(config)
107107

108108
# Check that pymc-devs/pymc PR link is formatted
109109
assert "[#456](https://github.com/pymc-devs/pymc/pull/456)" in content
@@ -144,7 +144,7 @@ def test_already_formatted_links_not_double_formatted(self):
144144
"RELEASE_URL": "https://github.com/pymc-devs/pymc/releases/tag/v1.0.0",
145145
}
146146

147-
title, content = format_release_content(config)
147+
_title, content = format_release_content(config)
148148

149149
# Already formatted link should remain unchanged
150150
assert "[#123](https://github.com/pymc-devs/pymc/pull/123)" in content
@@ -153,3 +153,46 @@ def test_already_formatted_links_not_double_formatted(self):
153153

154154
# Raw link should be formatted
155155
assert "[#456](https://github.com/pymc-devs/pymc/pull/456)" in content
156+
157+
def test_user_mentions_converted_to_links(self):
158+
"""Test that user mentions are converted to GitHub profile links."""
159+
release_body = """<!-- Release notes generated using configuration in .github/release.yml at main -->
160+
161+
## What's Changed
162+
### Major Changes 🛠
163+
* Bump PyTensor dependency by @ricardoV94 in https://github.com/pymc-devs/pymc/pull/7910
164+
* Remove deprecated parameter by @williambdean in https://github.com/pymc-devs/pymc/pull/7886
165+
166+
### New Features 🎉
167+
* Implement feature by @asifzubair in https://github.com/pymc-devs/pymc/pull/7884
168+
169+
### Bugfixes 🪲
170+
* Fix bug by @tomicapretto in https://github.com/pymc-devs/pymc/pull/7877
171+
172+
## New Contributors
173+
* @asifzubair made their first contribution in https://github.com/pymc-devs/pymc/pull/7871
174+
* @user-with-dashes contributed in https://github.com/pymc-devs/pymc/pull/7872
175+
* @another_user123 helped out in https://github.com/pymc-devs/pymc/pull/7873
176+
177+
**Full Changelog**: https://github.com/pymc-devs/pymc/compare/v5.25.1...v5.26.0"""
178+
179+
config = {
180+
"RELEASE_TAG": "v5.26.0",
181+
"REPO_NAME": "pymc-devs/pymc",
182+
"RELEASE_BODY": release_body,
183+
"RELEASE_URL": "https://github.com/pymc-devs/pymc/releases/tag/v5.26.0",
184+
}
185+
186+
_title, content = format_release_content(config)
187+
188+
# Check that user mentions are converted to links
189+
assert "[@ricardoV94](https://github.com/ricardoV94)" in content
190+
assert "[@williambdean](https://github.com/williambdean)" in content
191+
assert "[@asifzubair](https://github.com/asifzubair)" in content
192+
assert "[@tomicapretto](https://github.com/tomicapretto)" in content
193+
assert "[@user-with-dashes](https://github.com/user-with-dashes)" in content
194+
assert "[@another_user123](https://github.com/another_user123)" in content
195+
196+
# Check that PR links are still formatted correctly
197+
assert "[#7910](https://github.com/pymc-devs/pymc/pull/7910)" in content
198+
assert "[#7886](https://github.com/pymc-devs/pymc/pull/7886)" in content

0 commit comments

Comments
 (0)