Skip to content

Commit 9c0c0c2

Browse files
simonhampclaude
andauthored
Allow hyphens in GitHub username mentions in release notes (#390)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3ac3439 commit 9c0c0c2

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

app/Support/GitHub/Release.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getBodyForMarkdown(): string
6767
// Change any @ tags to markdown links to GitHub
6868
if ($this->withUserLinks) {
6969
$body = preg_replace(
70-
'/@([a-zA-Z0-9_]+)/',
70+
'/@([a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)/',
7171
'[@$1](https://github.com/$1)',
7272
$body
7373
);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Tests\Feature\Support\GitHub;
4+
5+
use App\Support\GitHub\Release;
6+
use Tests\TestCase;
7+
8+
class ReleaseTest extends TestCase
9+
{
10+
public function test_it_converts_at_mentions_to_github_user_links(): void
11+
{
12+
$release = new Release([
13+
'body' => 'Thanks to @simonhamp for the contribution.',
14+
]);
15+
16+
$this->assertStringContainsString(
17+
'[@simonhamp](https://github.com/simonhamp)',
18+
$release->getBodyForMarkdown(),
19+
);
20+
}
21+
22+
public function test_it_converts_at_mentions_containing_hyphens_to_github_user_links(): void
23+
{
24+
$release = new Release([
25+
'body' => 'Shout out to @some-user and @a-b-c for shipping this.',
26+
]);
27+
28+
$output = $release->getBodyForMarkdown();
29+
30+
$this->assertStringContainsString('[@some-user](https://github.com/some-user)', $output);
31+
$this->assertStringContainsString('[@a-b-c](https://github.com/a-b-c)', $output);
32+
}
33+
34+
public function test_it_does_not_match_trailing_hyphens_in_at_mentions(): void
35+
{
36+
$release = new Release([
37+
'body' => 'Mentioning @foo- bar',
38+
]);
39+
40+
$this->assertStringContainsString('[@foo](https://github.com/foo)- bar', $release->getBodyForMarkdown());
41+
}
42+
}

0 commit comments

Comments
 (0)