Make mergeable check more explicit

The 'mergeable' property of a change exists only if it is specifically
asked for, otherwise it is undefined. This was causing some false
positives when checking for merge conflicts.

Also removes some dead code.

Bug: Issue 6819
Change-Id: Ib42bac8067afacb09d20cd122f9d9f41425207e0
This commit is contained in:
Kasper Nilsson
2017-07-21 16:56:19 -07:00
parent f3862b6896
commit f73f8cf663
3 changed files with 17 additions and 5 deletions

View File

@@ -122,7 +122,8 @@ limitations under the License.
states.push('Merged');
} else if (change.status === this.ChangeStatus.ABANDONED) {
states.push('Abandoned');
} else if (!change.mergeable) {
} else if (change.mergeable === false) {
// 'mergeable' prop may not always exist (@see Issue 6819)
states.push('Merge Conflict');
}
if (change.work_in_progress) { states.push('WIP'); }

View File

@@ -100,11 +100,26 @@ limitations under the License.
current_revision: 'rev1',
status: 'NEW',
labels: {},
mergeable: false,
};
const status = element.changeStatusString(change);
assert.equal(status, 'Merge Conflict');
});
test('mergeable prop undefined', () => {
const change = {
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
revisions: {
rev1: {_number: 1},
},
current_revision: 'rev1',
status: 'NEW',
labels: {},
};
const status = element.changeStatusString(change);
assert.equal(status, '');
});
test('Merged status', () => {
const change = {
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',

View File

@@ -623,10 +623,6 @@
return Gerrit.Nav.getUrlForChange(change);
},
_privateChanges(change) {
return change.is_private ? ' (Private)' : '';
},
_computeShowCommitInfo(changeStatus, current_revision) {
return changeStatus === 'Merged' && current_revision;
},