Skip to content

Commit 98b565a

Browse files
committed
Plugins: update githubify for monotree PR mentions
1 parent 29e6cda commit 98b565a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

_plugins/githubify.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ def render(context)
2626
## Convert #1234 into URL for the pull request
2727
## If #1234 links to an issue, GitHub automatically redirects
2828
#
29-
## Require at least two digits to reduce false positive matches
30-
output.gsub!(/#([0-9][0-9][0-9]*)/){ |s|
31-
'<a href="' + @repository_url + '/pull/' + $1 + '">' + s + '</a>'
29+
## Main repository; forbid prefix of "/" to avoid conflation with
30+
## other monotree repos like bitcoin-core/gui. Require at least a
31+
## double-digit number to reduce false positive matches (e.g. "fix thing,
32+
## try #2")
33+
output.gsub!(/(^|[^\/])#([0-9]+)/){ |s|
34+
$1 + '<a href="' + @repository_url + '/pull/' + $2 + '">#' + $2 + '</a>'
35+
}
36+
37+
## Other monotree repos; for repo "bitcoin-core/foo", PR format is "foo/#123"
38+
output.gsub!(/([a-z]+)\/#([0-9]+)/){ |s|
39+
'<a href="https://github.com/bitcoin-core/' + $1 + '/pull/' + $2 + '">' + s + '</a>'
3240
}
3341

3442
## Convert `123abcd` into URL for the commit

0 commit comments

Comments
 (0)