Fix githubify helper
Conflicts: assets/scripts/app/helpers/helpers.coffee
This commit is contained in:
parent
5c280001d3
commit
17f2b9c821
|
@ -4,7 +4,6 @@ require 'helpers/urls'
|
||||||
config_keys_map = Travis.CONFIG_KEYS_MAP
|
config_keys_map = Travis.CONFIG_KEYS_MAP
|
||||||
config = Travis.config
|
config = Travis.config
|
||||||
githubCommitUrl = Travis.Urls.githubCommit
|
githubCommitUrl = Travis.Urls.githubCommit
|
||||||
currentDate = Travis.currentDate
|
|
||||||
timeago = $.timeago
|
timeago = $.timeago
|
||||||
intersect = $.intersect
|
intersect = $.intersect
|
||||||
only = $.only
|
only = $.only
|
||||||
|
@ -47,9 +46,9 @@ formatConfig = (config) ->
|
||||||
formatMessage = (message, options) ->
|
formatMessage = (message, options) ->
|
||||||
message = message || ''
|
message = message || ''
|
||||||
message = message.split(/\n/)[0] if options.short
|
message = message.split(/\n/)[0] if options.short
|
||||||
message = @_emojize(@_escape(message))
|
message = _emojize(_escape(message))
|
||||||
if !!options.repo
|
if !!options.repo
|
||||||
message = @githubify(message, options.repo.get('owner'), options.repo.get('name'))
|
message = githubify(message, options.repo.get('owner'), options.repo.get('name'))
|
||||||
if !!options.pre
|
if !!options.pre
|
||||||
message = message.replace /\n/g, '<br/>'
|
message = message.replace /\n/g, '<br/>'
|
||||||
message
|
message
|
||||||
|
@ -61,8 +60,8 @@ timeAgoInWords = (date) ->
|
||||||
timeago.distanceInWords date
|
timeago.distanceInWords date
|
||||||
|
|
||||||
durationFrom = (started, finished) ->
|
durationFrom = (started, finished) ->
|
||||||
started = started and @_toUtc(new Date(@_normalizeDateString(started)))
|
started = started and _toUtc(new Date(_normalizeDateString(started)))
|
||||||
finished = if finished then @_toUtc(new Date(@_normalizeDateString(finished))) else @_nowUtc()
|
finished = if finished then _toUtc(new Date(_normalizeDateString(finished))) else _nowUtc()
|
||||||
if started && finished then Math.round((finished - started) / 1000) else 0
|
if started && finished then Math.round((finished - started) / 1000) else 0
|
||||||
|
|
||||||
timeInWords = (duration) ->
|
timeInWords = (duration) ->
|
||||||
|
@ -82,13 +81,12 @@ timeInWords = (duration) ->
|
||||||
if result.length > 0 then result.join(' ') else '-'
|
if result.length > 0 then result.join(' ') else '-'
|
||||||
|
|
||||||
githubify = (text, owner, repo) ->
|
githubify = (text, owner, repo) ->
|
||||||
self = this
|
text = text.replace _githubReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedNumber) ->
|
||||||
text = text.replace @_githubReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedNumber) ->
|
_githubReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, number: matchedNumber } )
|
||||||
self._githubReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, number: matchedNumber } )
|
text = text.replace _githubUserRegexp, (reference, username) ->
|
||||||
text = text.replace @_githubUserRegexp, (reference, username) ->
|
_githubUserLink(reference, username)
|
||||||
self._githubUserLink(reference, username)
|
text = text.replace _githubCommitReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedSHA) ->
|
||||||
text = text.replace @_githubCommitReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedSHA) ->
|
_githubCommitReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, sha: matchedSHA })
|
||||||
self._githubCommitReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, sha: matchedSHA })
|
|
||||||
text
|
text
|
||||||
|
|
||||||
_githubReferenceRegexp = new RegExp("([\\w-]+)?\\/?([\\w-]+)?(?:#|gh-)(\\d+)", 'g')
|
_githubReferenceRegexp = new RegExp("([\\w-]+)?\\/?([\\w-]+)?(?:#|gh-)(\\d+)", 'g')
|
||||||
|
@ -118,7 +116,9 @@ _normalizeDateString = (string) ->
|
||||||
string
|
string
|
||||||
|
|
||||||
_nowUtc = ->
|
_nowUtc = ->
|
||||||
@_toUtc currentDate()
|
# TODO: we overwrite Travis.currentDate in tests, so we need to leave this
|
||||||
|
# global usage as it is for now, but it should be removed at some point
|
||||||
|
_toUtc Travis.currentDate()
|
||||||
|
|
||||||
_toUtc = (date) ->
|
_toUtc = (date) ->
|
||||||
Date.UTC date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()
|
Date.UTC date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user