Detect and link-ify github commit ref in log

Addresses https://github.com/travis-ci/travis-ci/issues/1470
This commit is contained in:
Hiro Asari 2014-01-11 13:40:23 -05:00
parent 97d73ad98c
commit 9ed3e66206

View File

@ -75,6 +75,8 @@ require 'config/emoij'
self._githubReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, number: matchedNumber } )
text = text.replace @_githubUserRegexp, (reference, username) ->
self._githubUserLink(reference, username)
text = text.replace @_githubCommitReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedSHA) ->
self._githubCommitReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, sha: matchedSHA })
text
_githubReferenceLink: (reference, current, matched) ->
@ -86,6 +88,13 @@ require 'config/emoij'
_githubUserRegexp: new RegExp("\\B@([\\w-]+)", 'g')
_githubCommitReferenceRegexp: new RegExp("([\\w-]+)?\\/([\\w-]+)?@([0-9A-Fa-f]+)", 'g')
_githubCommitReferenceLink: (reference, current, matched) ->
owner = matched.owner || current.owner
repo = matched.repo || current.repo
"<a href=\"http://github.com/#{owner}/#{repo}/commit/#{matched.sha}\">#{reference}</a>"
_githubUserLink: (reference, username) ->
"<a href=\"http://github.com/#{username}\">#{reference}</a>"