Fix parent in gr-change-metadata when switching patchsets
Bug: Issue 12775
Change-Id: I33c88df5e01b9659256b11f70df7f9442cb5cb9e
(cherry picked from commit a37843174c)
This commit is contained in:
@@ -131,7 +131,7 @@
|
||||
|
||||
_currentParents: {
|
||||
type: Array,
|
||||
computed: '_computeParents(change)',
|
||||
computed: '_computeParents(revision)',
|
||||
},
|
||||
|
||||
/** @type {?} */
|
||||
@@ -445,13 +445,11 @@
|
||||
return null;
|
||||
},
|
||||
|
||||
_computeParents(change) {
|
||||
if (!change.current_revision ||
|
||||
!change.revisions[change.current_revision] ||
|
||||
!change.revisions[change.current_revision].commit) {
|
||||
_computeParents(revision) {
|
||||
if (!revision || !revision.commit) {
|
||||
return undefined;
|
||||
}
|
||||
return change.revisions[change.current_revision].commit.parents;
|
||||
return revision.commit.parents;
|
||||
},
|
||||
|
||||
_computeParentsLabel(parents) {
|
||||
|
||||
@@ -429,14 +429,20 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('_computeParents', () => {
|
||||
const parents = [{commit: '123', subject: 'abc'}];
|
||||
assert.isUndefined(element._computeParents(
|
||||
{revisions: {456: {commit: {parents}}}}));
|
||||
assert.isUndefined(element._computeParents(
|
||||
{current_revision: '789', revisions: {456: {commit: {parents}}}}));
|
||||
assert.equal(element._computeParents(
|
||||
{current_revision: '456', revisions: {456: {commit: {parents}}}}),
|
||||
parents);
|
||||
const revision = {commit: {parents: [{commit: '123', subject: 'abc'}]}};
|
||||
assert.isUndefined(element._computeParents({}));
|
||||
assert.equal(element._computeParents(revision), revision.commit.parents);
|
||||
});
|
||||
|
||||
test('_currentParents', () => {
|
||||
element.revision = {
|
||||
commit: {parents: [{commit: '123', subject: 'abc'}]},
|
||||
};
|
||||
assert.equal(element._currentParents[0].commit, '123');
|
||||
element.revision = {
|
||||
commit: {parents: [{commit: '12345', subject: 'abc'}]},
|
||||
};
|
||||
assert.equal(element._currentParents[0].commit, '12345');
|
||||
});
|
||||
|
||||
test('_computeParentsLabel', () => {
|
||||
|
||||
Reference in New Issue
Block a user