Fix selecting AutoMerge
This fixes it so when you navigate between merge commits, auto merge will be selected if patchNum is defined. Also this makes sure that if you have first parent selected in your preference it won't default to it if patchNum is defined. Bug: Issue 10670 Change-Id: I732651de5997053252c2c5b07865e05121b242e0
This commit is contained in:
@@ -808,9 +808,8 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets base patch number, if is a parent try and
|
||||
* decide from preference weather to default to `auto merge`
|
||||
* or `Parent 1`.
|
||||
* Gets base patch number, if it is a parent try and decide from
|
||||
* preference weather to default to `auto merge`, `Parent 1` or `PARENT`.
|
||||
* @param {Object} change
|
||||
* @param {Object} patchRange
|
||||
* @return {number|string}
|
||||
@@ -833,7 +832,11 @@
|
||||
const preferFirst = this._prefs &&
|
||||
this._prefs.default_base_for_merges === 'FIRST_PARENT';
|
||||
|
||||
return parentCount > 1 && preferFirst ? -1 : 'PARENT';
|
||||
if (parentCount > 1 && preferFirst && !patchRange.patchNum) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 'PARENT';
|
||||
},
|
||||
|
||||
_computeChangeUrl(change) {
|
||||
|
@@ -1020,6 +1020,53 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('_getBasePatchNum', () => {
|
||||
const _change = {
|
||||
_number: 42,
|
||||
revisions: {
|
||||
'98da160735fb81604b4c40e93c368f380539dd0e': {
|
||||
_number: 1,
|
||||
commit: {
|
||||
parents: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const _patchRange = {
|
||||
basePatchNum: 'PARENT',
|
||||
};
|
||||
assert.equal(element._getBasePatchNum(_change, _patchRange), 'PARENT');
|
||||
|
||||
element._prefs = {
|
||||
default_base_for_merges: 'FIRST_PARENT',
|
||||
};
|
||||
|
||||
const _change2 = {
|
||||
_number: 42,
|
||||
revisions: {
|
||||
'98da160735fb81604b4c40e93c368f380539dd0e': {
|
||||
_number: 1,
|
||||
commit: {
|
||||
parents: [
|
||||
{
|
||||
commit: '6e12bdf1176eb4ab24d8491ba3b6d0704409cde8',
|
||||
subject: 'test',
|
||||
},
|
||||
{
|
||||
commit: '22f7db4754b5d9816fc581f3d9a6c0ef8429c841',
|
||||
subject: 'test3',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
assert.equal(element._getBasePatchNum(_change2, _patchRange), -1);
|
||||
|
||||
_patchRange.patchNum = 1;
|
||||
assert.equal(element._getBasePatchNum(_change2, _patchRange), 'PARENT');
|
||||
});
|
||||
|
||||
test('_openReplyDialog called with `ANY` when coming from tap event',
|
||||
() => {
|
||||
const openStub = sandbox.stub(element, '_openReplyDialog');
|
||||
|
Reference in New Issue
Block a user