diff --git a/contrib/buildbot/server.py b/contrib/buildbot/server.py --- a/contrib/buildbot/server.py +++ b/contrib/buildbot/server.py @@ -182,7 +182,7 @@ # Only link PRs that do not reside in code blocks if multilineCodeBlockDelimiters % 2 == 0: - def replacePRWithLink(baseUrl): + def replacePRWithLink(baseUrl, prefix): def repl(match): nonlocal foundPRs # This check matches identation-based code blocks (2+ spaces) @@ -201,21 +201,21 @@ if len(match.groups()) >= 2: remaining = match.group(2) - return '[[{}/{} | PR{}]]{}'.format( - baseUrl, PRNum, PRNum, remaining) + return '[[{}/{} | {}#{}]]{}'.format( + baseUrl, PRNum, prefix, PRNum, remaining) return repl - line = re.sub( - r'PR[ #]*(\d{3}\d+)', - replacePRWithLink( - 'https://github.com/bitcoin/bitcoin/pull'), - line) - - # Be less aggressive about serving libsecp256k1 links. Check - # for some reference to the name first. - if re.search('secp', line, re.IGNORECASE): - line = re.sub(r'PR[ #]*(\d{2}\d?)([^\d]|$)', replacePRWithLink( - 'https://github.com/bitcoin-core/secp256k1/pull'), line) + githubUrl = 'https://github.com/{}/pull' + supportedRepos = { + 'Core': githubUrl.format('bitcoin/bitcoin'), + 'core-gui': githubUrl.format('bitcoin-core/gui'), + 'secp256k1': githubUrl.format('bitcoin-core/secp256k1') + } + + for prefix, url in supportedRepos.values: + regEx = r'{}#\d+'.format(prefix) + line = re.sub(regEx, replacePRWithLink( + url, prefix), line) newSummary += line