Merge "blame: Add base url to _getBlameForBaseLine" into stable-3.2

This commit is contained in:
Paladox none
2020-07-14 17:32:56 +00:00
committed by Gerrit Code Review
2 changed files with 8 additions and 1 deletions

View File

@@ -54,6 +54,7 @@ import './gr-diff-builder.js';
import '../../shared/gr-rest-api-interface/gr-rest-api-interface.js';
import {getMockDiffResponse} from '../../../test/mock-diff-response.js';
import './gr-diff-builder-element.js';
import {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.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';
@@ -79,6 +80,7 @@ suite('gr-diff-builder tests', () => {
getLoggedIn() { return Promise.resolve(false); },
getProjectConfig() { return Promise.resolve({}); },
});
sandbox.stub(BaseUrlBehavior, 'getBaseUrl').returns('/r');
prefs = {
line_length: 10,
show_tabs: true,
@@ -1222,6 +1224,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 {BaseUrlBehavior} from '../../../behaviors/base-url-behavior/base-url-behavior.js';
import {GrDiffLine} from '../gr-diff/gr-diff-line.js';
import {GrDiffGroup} from '../gr-diff/gr-diff-group.js';
@@ -579,7 +580,8 @@ 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',
`${BaseUrlBehavior.getBaseUrl()}/q/${commit.id}`);
blameNode.appendChild(shaNode);
const shortName = commit.author.split(' ')[0];