From 17f2b9c8215b45dbcce4d5b954276044e02c264c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 15 Jan 2015 12:23:47 +0100 Subject: [PATCH] Fix githubify helper Conflicts: assets/scripts/app/helpers/helpers.coffee --- assets/scripts/app/helpers/helpers.coffee | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/assets/scripts/app/helpers/helpers.coffee b/assets/scripts/app/helpers/helpers.coffee index 42cd88f1..385035dd 100644 --- a/assets/scripts/app/helpers/helpers.coffee +++ b/assets/scripts/app/helpers/helpers.coffee @@ -4,7 +4,6 @@ require 'helpers/urls' config_keys_map = Travis.CONFIG_KEYS_MAP config = Travis.config githubCommitUrl = Travis.Urls.githubCommit -currentDate = Travis.currentDate timeago = $.timeago intersect = $.intersect only = $.only @@ -47,9 +46,9 @@ formatConfig = (config) -> formatMessage = (message, options) -> message = message || '' message = message.split(/\n/)[0] if options.short - message = @_emojize(@_escape(message)) + message = _emojize(_escape(message)) 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 message = message.replace /\n/g, '
' message @@ -61,8 +60,8 @@ timeAgoInWords = (date) -> timeago.distanceInWords date durationFrom = (started, finished) -> - started = started and @_toUtc(new Date(@_normalizeDateString(started))) - finished = if finished then @_toUtc(new Date(@_normalizeDateString(finished))) else @_nowUtc() + started = started and _toUtc(new Date(_normalizeDateString(started))) + finished = if finished then _toUtc(new Date(_normalizeDateString(finished))) else _nowUtc() if started && finished then Math.round((finished - started) / 1000) else 0 timeInWords = (duration) -> @@ -82,13 +81,12 @@ timeInWords = (duration) -> if result.length > 0 then result.join(' ') else '-' githubify = (text, owner, repo) -> - self = this - text = text.replace @_githubReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedNumber) -> - 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 = text.replace _githubReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedNumber) -> + _githubReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, number: matchedNumber } ) + text = text.replace _githubUserRegexp, (reference, username) -> + _githubUserLink(reference, username) + text = text.replace _githubCommitReferenceRegexp, (reference, matchedOwner, matchedRepo, matchedSHA) -> + _githubCommitReferenceLink(reference, { owner: owner, repo: repo }, { owner: matchedOwner, repo: matchedRepo, sha: matchedSHA }) text _githubReferenceRegexp = new RegExp("([\\w-]+)?\\/?([\\w-]+)?(?:#|gh-)(\\d+)", 'g') @@ -118,7 +116,9 @@ _normalizeDateString = (string) -> string _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) -> Date.UTC date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()