Merge "Patch optional commit field on CommitInfo response if missing"

This commit is contained in:
Viktar Donich
2016-11-29 22:00:10 +00:00
committed by Gerrit Code Review
2 changed files with 23 additions and 2 deletions

View File

@@ -689,8 +689,8 @@
if (!change.reviewer_updates) {
change.reviewer_updates = null;
}
var currentRevision =
change.revisions[this._getLatestRevisionSHA(change)];
var latestRevisionSha = this._getLatestRevisionSHA(change);
var currentRevision = change.revisions[latestRevisionSha];
if (currentRevision.commit && currentRevision.commit.message) {
this._latestCommitMessage = currentRevision.commit.message;
} else {
@@ -700,6 +700,10 @@
this._change = change;
if (!this._patchRange || !this._patchRange.patchNum ||
this._patchRange.patchNum === currentRevision._number) {
// CommitInfo.commit is optional, and may need patching.
if (!currentRevision.commit.commit) {
currentRevision.commit.commit = latestRevisionSha;
}
this._commitInfo = currentRevision.commit;
this._currentRevisionActions = currentRevision.actions;
// TODO: Fetch and process files.

View File

@@ -498,6 +498,23 @@ limitations under the License.
});
});
test('commit sha is populated from getChangeDetail', function(done) {
sandbox.stub(element, '_changeChanged');
sandbox.stub(element.$.restAPI, 'getChangeDetail', function() {
return Promise.resolve({
id: '123456789',
labels: {},
current_revision: 'foo',
revisions: {foo: {commit: {}}},
});
});
element._getChangeDetail().then(function() {
assert.equal('foo', element._commitInfo.commit);
done();
});
});
test('reply dialog focus can be controlled', function() {
var FocusTarget = element.$.replyDialog.FocusTarget;
var openSpy = sandbox.spy(element, '_openReplyDialog');