Merge "Do not repeatedly add the 'revert' message modifications"
This commit is contained in:
@@ -274,6 +274,7 @@
|
||||
if (type === ActionType.REVISION) {
|
||||
this._handleRevisionAction(key);
|
||||
} else if (key === ChangeActions.REVERT) {
|
||||
this.$.confirmRevertDialog.populateRevertMessage();
|
||||
this.$.confirmRevertDialog.message = this._modifyRevertMsg();
|
||||
this._showActionDialog(this.$.confirmRevertDialog);
|
||||
} else if (key === ChangeActions.ABANDON) {
|
||||
|
||||
@@ -244,18 +244,25 @@ limitations under the License.
|
||||
var newRevertMsg = 'Modified revert msg';
|
||||
var modifyRevertMsgStub = sinon.stub(element, '_modifyRevertMsg',
|
||||
function() { return newRevertMsg; });
|
||||
var populateRevertMsgStub = sinon.stub(
|
||||
element.$.confirmRevertDialog, 'populateRevertMessage',
|
||||
function() { return 'original msg'; });
|
||||
flush(function() {
|
||||
var revertButton = element.$$('gr-button[data-action-key="revert"]');
|
||||
MockInteractions.tap(revertButton);
|
||||
|
||||
assert.equal(element.$.confirmRevertDialog.message, newRevertMsg);
|
||||
|
||||
populateRevertMsgStub.restore();
|
||||
modifyRevertMsgStub.restore();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('works', function() {
|
||||
var populateRevertMsgStub = sinon.stub(
|
||||
element.$.confirmRevertDialog, 'populateRevertMessage',
|
||||
function() { return 'original msg'; });
|
||||
var revertButton = element.$$('gr-button[data-action-key="revert"]');
|
||||
MockInteractions.tap(revertButton);
|
||||
|
||||
@@ -276,6 +283,7 @@ limitations under the License.
|
||||
'/revert', action, false, {
|
||||
message: 'foo message',
|
||||
}]);
|
||||
populateRevertMsgStub.restore();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,15 +32,12 @@
|
||||
properties: {
|
||||
branch: String,
|
||||
message: String,
|
||||
commitInfo: {
|
||||
type: Object,
|
||||
observer: '_commitInfoChanged',
|
||||
},
|
||||
commitInfo: Object,
|
||||
},
|
||||
|
||||
_commitInfoChanged: function(commitInfo) {
|
||||
populateRevertMessage: function() {
|
||||
// Figure out what the revert title should be.
|
||||
var originalTitle = commitInfo.message.split('\n')[0];
|
||||
var originalTitle = this.commitInfo.message.split('\n')[0];
|
||||
var revertTitle = 'Revert of ' + originalTitle;
|
||||
if (originalTitle.startsWith('Revert of ')) {
|
||||
revertTitle = 'Reland of ' +
|
||||
@@ -50,7 +47,7 @@
|
||||
originalTitle.substring('Reland of '.length);
|
||||
}
|
||||
// Add '> ' in front of the original commit text.
|
||||
var originalCommitText = commitInfo.message.replace(/^/gm, '> ');
|
||||
var originalCommitText = this.commitInfo.message.replace(/^/gm, '> ');
|
||||
|
||||
this.message = revertTitle + '\n\n' +
|
||||
'Reason for revert: <INSERT REASONING HERE>\n\n' +
|
||||
|
||||
@@ -39,9 +39,10 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('single line', function() {
|
||||
assert(element.message == null);
|
||||
element.commitInfo = { message: 'one line commit' };
|
||||
console.log(element.message);
|
||||
assert.isNotOk(element.message);
|
||||
element.commitInfo = {message: 'one line commit'};
|
||||
assert.isNotOk(element.message);
|
||||
element.populateRevertMessage();
|
||||
var expected = 'Revert of one line commit\n\n' +
|
||||
'Reason for revert: <INSERT REASONING HERE>\n\n' +
|
||||
'Original issue\'s description:\n' +
|
||||
@@ -50,9 +51,10 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('multi line', function() {
|
||||
assert(element.message == null);
|
||||
element.commitInfo = { message: 'many lines\ncommit\n\nmessage\n' };
|
||||
console.log(element.message);
|
||||
assert.isNotOk(element.message);
|
||||
element.commitInfo = {message: 'many lines\ncommit\n\nmessage\n'};
|
||||
assert.isNotOk(element.message);
|
||||
element.populateRevertMessage();
|
||||
var expected = 'Revert of many lines\n\n' +
|
||||
'Reason for revert: <INSERT REASONING HERE>\n\n' +
|
||||
'Original issue\'s description:\n' +
|
||||
|
||||
Reference in New Issue
Block a user