Merge "Fix short commit hash link"

This commit is contained in:
Andrew Bonventre
2016-06-08 19:58:07 +00:00
committed by Gerrit Code Review
3 changed files with 20 additions and 5 deletions

View File

@@ -110,10 +110,10 @@ limitations under the License.
<span class="value">
<template is="dom-if" if="[[_showWebLink]]">
<a target="_blank"
href$="[[_webLink]]">[[_computeShortHash(change)]]</a>
href$="[[_webLink]]">[[_computeShortHash(commitInfo)]]</a>
</template>
<template is="dom-if" if="[[!_showWebLink]]">
[[_computeShortHash(change)]]
[[_computeShortHash(commitInfo)]]
</template>
</span>
</section>

View File

@@ -68,11 +68,16 @@
.replace('${commit}', commitInfo.commit);
}
return '../../' + commitInfo.web_links[0].url;
var webLink = commitInfo.web_links[0].url;
if (!/^https?\:\/\//.test(webLink)) {
webLink = '../../' + webLink;
}
return webLink;
},
_computeShortHash: function(change) {
return change.current_revision.slice(0, 7);
_computeShortHash: function(commitInfo) {
return commitInfo.commit.slice(0, 7);
},
_computeHideStrategy: function(change) {

View File

@@ -87,6 +87,16 @@ limitations under the License.
element.serverConfig), '../../link-url');
});
test('does not relativize web links that begin with scheme', function() {
element.commitInfo = {web_links: [{url: 'https://link-url'}]};
element.serverConfig = {};
assert.isOk(element._computeShowWebLink(element.change,
element.commitInfo, element.serverConfig));
assert.equal(element._computeWebLink(element.change, element.commitInfo,
element.serverConfig), 'https://link-url');
});
test('use gitweb when available', function() {
element.commitInfo = {commit: 'commit-sha'};
element.serverConfig = {gitweb: {