From add1b8f0f9a8af6af05e23805be888dc595fcd10 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 20 May 2026 00:44:07 +0100 Subject: [PATCH] Allow hyphens in GitHub username mentions in release notes Co-Authored-By: Claude Opus 4.7 (1M context) --- app/Support/GitHub/Release.php | 2 +- tests/Feature/Support/GitHub/ReleaseTest.php | 42 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/Support/GitHub/ReleaseTest.php diff --git a/app/Support/GitHub/Release.php b/app/Support/GitHub/Release.php index 30130478..11522465 100644 --- a/app/Support/GitHub/Release.php +++ b/app/Support/GitHub/Release.php @@ -67,7 +67,7 @@ public function getBodyForMarkdown(): string // Change any @ tags to markdown links to GitHub if ($this->withUserLinks) { $body = preg_replace( - '/@([a-zA-Z0-9_]+)/', + '/@([a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)/', '[@$1](https://github.com/$1)', $body ); diff --git a/tests/Feature/Support/GitHub/ReleaseTest.php b/tests/Feature/Support/GitHub/ReleaseTest.php new file mode 100644 index 00000000..593931f1 --- /dev/null +++ b/tests/Feature/Support/GitHub/ReleaseTest.php @@ -0,0 +1,42 @@ + 'Thanks to @simonhamp for the contribution.', + ]); + + $this->assertStringContainsString( + '[@simonhamp](https://github.com/simonhamp)', + $release->getBodyForMarkdown(), + ); + } + + public function test_it_converts_at_mentions_containing_hyphens_to_github_user_links(): void + { + $release = new Release([ + 'body' => 'Shout out to @some-user and @a-b-c for shipping this.', + ]); + + $output = $release->getBodyForMarkdown(); + + $this->assertStringContainsString('[@some-user](https://github.com/some-user)', $output); + $this->assertStringContainsString('[@a-b-c](https://github.com/a-b-c)', $output); + } + + public function test_it_does_not_match_trailing_hyphens_in_at_mentions(): void + { + $release = new Release([ + 'body' => 'Mentioning @foo- bar', + ]); + + $this->assertStringContainsString('[@foo](https://github.com/foo)- bar', $release->getBodyForMarkdown()); + } +}