blame: Add base url to _getBlameForBaseLine

Change-Id: I4f60801383ec07a1a0997da0226f685ad9faec16
This commit is contained in:
Paladox none
2020-07-03 20:40:40 +00:00
parent 225fd6120b
commit 87aa6beda0
2 changed files with 7 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ import './gr-diff-builder.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import {getMockDiffResponse} from '../../../test/mocks/diff-response.js';
import './gr-diff-builder-element.js';
import {stubBaseUrl} from '../../../test/test-utils.js';
import {dom, flush} from '@polymer/polymer/lib/legacy/polymer.dom.js';
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation.js';
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
@@ -62,6 +63,7 @@ suite('gr-diff-builder tests', () => {
getLoggedIn() { return Promise.resolve(false); },
getProjectConfig() { return Promise.resolve({}); },
});
stubBaseUrl('/r');
prefs = {
line_length: 10,
show_tabs: true,
@@ -1230,6 +1232,9 @@ suite('gr-diff-builder tests', () => {
`Commit 1234567890<br>Author: Clark Kent<br>Date: ${date}`
+ '<br><br>Testing Commit'
);
const url = blameNode.getElementsByClassName('blameDate');
assert.equal(url[0].getAttribute('href'), '/r/q/1234567890');
});
});
});

View File

@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {getBaseUrl} from '../../../utils/url-util.js';
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
import {GrDiffGroup} from '../gr-diff/gr-diff-group.js';
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
@@ -611,7 +612,7 @@ GrDiffBuilder.prototype._getBlameForBaseLine = function(lineNum, opt_commit) {
const shaNode = this._createElement('a', 'blameDate');
shaNode.innerText = `${date}`;
shaNode.setAttribute('href', `/q/${commit.id}`);
shaNode.setAttribute('href', `${getBaseUrl()}/q/${commit.id}`);
blameNode.appendChild(shaNode);
const shortName = commit.author.split(' ')[0];