summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/change/gr-change-actions
diff options
context:
space:
mode:
Diffstat (limited to 'polygerrit-ui/app/elements/change/gr-change-actions')
-rw-r--r--polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html10
-rw-r--r--polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js30
-rw-r--r--polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html32
3 files changed, 65 insertions, 7 deletions
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
index 6b6e90bf1e..278875e7e4 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
@@ -32,6 +32,7 @@ limitations under the License.
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.html">
<link rel="import" href="../gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.html">
+<link rel="import" href="../gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.html">
<link rel="import" href="../gr-confirm-move-dialog/gr-confirm-move-dialog.html">
<link rel="import" href="../gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.html">
<link rel="import" href="../gr-confirm-revert-dialog/gr-confirm-revert-dialog.html">
@@ -187,6 +188,15 @@ limitations under the License.
on-cancel="_handleConfirmDialogCancel"
project="[[change.project]]"
hidden></gr-confirm-cherrypick-dialog>
+ <gr-confirm-cherrypick-conflict-dialog id="confirmCherrypickConflict"
+ class="confirmDialog"
+ change-status="[[changeStatus]]"
+ commit-message="[[commitMessage]]"
+ commit-num="[[commitNum]]"
+ on-confirm="_handleCherrypickConflictConfirm"
+ on-cancel="_handleConfirmDialogCancel"
+ project="[[change.project]]"
+ hidden></gr-confirm-cherrypick-conflict-dialog>
<gr-confirm-move-dialog id="confirmMove"
class="confirmDialog"
on-confirm="_handleMoveConfirm"
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index 368b11b5a2..3e5c4f760c 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -991,6 +991,14 @@
},
_handleCherrypickConfirm() {
+ this._handleCherryPickRestApi(false);
+ },
+
+ _handleCherrypickConflictConfirm() {
+ this._handleCherryPickRestApi(true);
+ },
+
+ _handleCherryPickRestApi(conflicts) {
const el = this.$.confirmCherrypick;
if (!el.branch) {
// TODO(davido): Fix error handling
@@ -1011,6 +1019,7 @@
destination: el.branch,
base: el.baseCommit ? el.baseCommit : null,
message: el.message,
+ allow_conflicts: conflicts,
}
);
},
@@ -1113,8 +1122,9 @@
_fireAction(endpoint, action, revAction, opt_payload) {
const cleanupFn =
this._setLoadingOnButtonWithKey(action.__type, action.__key);
- this._send(action.method, opt_payload, endpoint, revAction, cleanupFn)
- .then(this._handleResponse.bind(this, action));
+
+ this._send(action.method, opt_payload, endpoint, revAction, cleanupFn,
+ action).then(this._handleResponse.bind(this, action));
},
_showActionDialog(dialog) {
@@ -1171,7 +1181,14 @@
});
},
- _handleResponseError(response) {
+ _handleResponseError(action, response, body) {
+ if (action && action.__key === RevisionActions.CHERRYPICK) {
+ if (response && response.status === 409 &&
+ body && !body.allow_conflicts) {
+ return this._showActionDialog(
+ this.$.confirmCherrypickConflict);
+ }
+ }
return response.text().then(errText => {
this.fire('show-error',
{message: `Could not perform action: ${errText}`});
@@ -1187,13 +1204,12 @@
* @param {string} actionEndpoint
* @param {boolean} revisionAction
* @param {?Function} cleanupFn
- * @param {?Function=} opt_errorFn
+ * @param {!Object|undefined} action
*/
- _send(method, payload, actionEndpoint, revisionAction, cleanupFn,
- opt_errorFn) {
+ _send(method, payload, actionEndpoint, revisionAction, cleanupFn, action) {
const handleError = response => {
cleanupFn.call(this);
- this._handleResponseError(response);
+ this._handleResponseError(action, response, payload);
};
return this.fetchChangeUpdates(this.change, this.$.restAPI)
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
index 96ef5ff135..81fe54ef65 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
@@ -597,6 +597,38 @@ limitations under the License.
destination: 'master',
base: null,
message: 'foo message',
+ allow_conflicts: false,
+ },
+ ]);
+ });
+
+ test('cherry pick even with conflicts', () => {
+ element._handleCherrypickTap();
+ const action = {
+ __key: 'cherrypick',
+ __type: 'revision',
+ __primary: false,
+ enabled: true,
+ label: 'Cherry pick',
+ method: 'POST',
+ title: 'Cherry pick change to a different branch',
+ };
+
+ element.$.confirmCherrypick.branch = 'master';
+
+ // Add attributes that are used to determine the message.
+ element.$.confirmCherrypick.commitMessage = 'foo message';
+ element.$.confirmCherrypick.changeStatus = 'OPEN';
+ element.$.confirmCherrypick.commitNum = '123';
+
+ element._handleCherrypickConflictConfirm();
+
+ assert.deepEqual(fireActionStub.lastCall.args, [
+ '/cherrypick', action, true, {
+ destination: 'master',
+ base: null,
+ message: 'foo message',
+ allow_conflicts: true,
},
]);
});