From 5d72078537c18d916945b45f08882c25cdb5d8c8 Mon Sep 17 00:00:00 2001 From: Paladox none Date: Thu, 11 Oct 2018 22:36:26 +0000 Subject: Add support for cherry-picking even with merge conflicts Supported since [1] [1] Iae9eef38ad2a7810a736823c7bd80b8a7a2a214f Bug: Issue 5728 Change-Id: Idb749f77cc7063eb9d93ebbf7a10d81bc5384750 (cherry picked from commit 35c3de368f3a1ad207a7f164247cdfb2e9f8b35a) --- .../gr-change-actions/gr-change-actions.html | 10 ++++ .../change/gr-change-actions/gr-change-actions.js | 30 +++++++--- .../gr-change-actions/gr-change-actions_test.html | 32 +++++++++++ .../gr-confirm-cherrypick-conflict-dialog.html | 51 +++++++++++++++++ .../gr-confirm-cherrypick-conflict-dialog.js | 45 +++++++++++++++ ...gr-confirm-cherrypick-conflict-dialog_test.html | 65 ++++++++++++++++++++++ polygerrit-ui/app/test/index.html | 1 + 7 files changed, 227 insertions(+), 7 deletions(-) create mode 100644 polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.html create mode 100644 polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js create mode 100644 polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog_test.html 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. + @@ -187,6 +188,15 @@ limitations under the License. on-cancel="_handleConfirmDialogCancel" project="[[change.project]]" hidden> + { 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, }, ]); }); diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.html b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.html new file mode 100644 index 0000000000..cd196eceae --- /dev/null +++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.html @@ -0,0 +1,51 @@ + + + + + + + + + + diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js new file mode 100644 index 0000000000..355aa78c63 --- /dev/null +++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js @@ -0,0 +1,45 @@ +/** + * @license + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function() { + 'use strict'; + + Polymer({ + is: 'gr-confirm-cherrypick-conflict-dialog', + + /** + * Fired when the confirm button is pressed. + * + * @event confirm + */ + + /** + * Fired when the cancel button is pressed. + * + * @event cancel + */ + + _handleConfirmTap(e) { + e.preventDefault(); + this.fire('confirm', null, {bubbles: false}); + }, + + _handleCancelTap(e) { + e.preventDefault(); + this.fire('cancel', null, {bubbles: false}); + }, + }); +})(); diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog_test.html b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog_test.html new file mode 100644 index 0000000000..77b102ca2c --- /dev/null +++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog_test.html @@ -0,0 +1,65 @@ + + + + +gr-confirm-cherrypick-conflict-dialog + + + + + + + + + + + + + diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html index 94a48d31a4..5784eadec7 100644 --- a/polygerrit-ui/app/test/index.html +++ b/polygerrit-ui/app/test/index.html @@ -71,6 +71,7 @@ limitations under the License. 'change/gr-commit-info/gr-commit-info_test.html', 'change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_test.html', 'change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.html', + 'change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog_test.html', 'change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.html', 'change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog_test.html', 'change/gr-confirm-revert-dialog/gr-confirm-revert-dialog_test.html', -- cgit v1.2.3