Add support for custom commit links in the build UI

Fixes #1251
This commit is contained in:
Joseph Schorr 2016-07-26 16:06:41 -07:00
parent 9d48bcd0f1
commit dcebd61dde
2 changed files with 13 additions and 2 deletions

View file

@ -27,8 +27,8 @@
<!-- Full Commit Information -->
<div class="tbd-content" ng-switch-when="fullcommit">
<div class="commit-message">
<span class="anchor" is-only-text="!TriggerService.getFullLinkTemplate(build, 'commit')"
ng-safenewtab href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', TriggerService.getCommitSHA(build.trigger_metadata)) }}">
<span class="anchor" is-only-text="!TriggerService.getCommitUrl(build)"
ng-safenewtab href="{{ TriggerService.getCommitUrl(build) }}">
{{ getMessageSummary(build.trigger_metadata.commit_info.message) }}
</span>
<span class="long-description-toggle"

View file

@ -135,6 +135,17 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
});
};
triggerService.getCommitUrl = function(build) {
// Check for a predefined URL first.
if (build.trigger_metadata && build.trigger_metadata.commit_info &&
build.trigger_metadata.commit_info.url) {
return build.trigger_metadata.commit_info.url;
}
return triggerService.getFullLinkTemplate(build, 'commit')
.replace('{sha}', triggerService.getCommitSHA(build.trigger_metadata))
};
triggerService.getFullLinkTemplate = function(build, templateName) {
var name = build.trigger.service;
var type = triggerTypes[name];